glsl: Fix blob memory leak
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
parent
a4c4efad89
commit
bcb63ee63e
|
@ -27,6 +27,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -79,6 +80,16 @@ struct blob_reader {
|
|||
struct blob *
|
||||
blob_create(void);
|
||||
|
||||
/**
|
||||
* Destroy a blob and free its memory.
|
||||
*/
|
||||
static inline void
|
||||
blob_destroy(struct blob *blob)
|
||||
{
|
||||
free(blob->data);
|
||||
free(blob);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add some unstructured, fixed-size data to a blob.
|
||||
*
|
||||
|
|
|
@ -1273,7 +1273,7 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
|
|||
|
||||
disk_cache_put(cache, prog->data->sha1, metadata->data, metadata->size);
|
||||
|
||||
free(metadata);
|
||||
blob_destroy(metadata);
|
||||
|
||||
if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
|
||||
_mesa_sha1_format(sha1_buf, prog->data->sha1);
|
||||
|
|
|
@ -184,7 +184,7 @@ test_write_and_read_functions (void)
|
|||
"read_consumes_all_bytes");
|
||||
expect_equal(false, reader.overrun, "read_does_not_overrun");
|
||||
|
||||
free(blob);
|
||||
blob_destroy(blob);
|
||||
}
|
||||
|
||||
/* Test that data values are written and read with proper alignment. */
|
||||
|
@ -242,7 +242,7 @@ test_alignment(void)
|
|||
"aligned read of intptr_t");
|
||||
}
|
||||
|
||||
free(blob);
|
||||
blob_destroy(blob);
|
||||
}
|
||||
|
||||
/* Test that we detect overrun. */
|
||||
|
@ -264,7 +264,7 @@ test_overrun(void)
|
|||
expect_equal(0, blob_read_uint32(&reader), "read at overrun");
|
||||
expect_equal(true, reader.overrun, "overrun flag set");
|
||||
|
||||
free(blob);
|
||||
blob_destroy(blob);
|
||||
}
|
||||
|
||||
/* Test that we can read and write some large objects, (exercising the code in
|
||||
|
@ -308,7 +308,7 @@ test_big_objects(void)
|
|||
expect_equal(false, reader.overrun,
|
||||
"overrun flag not set reading large objects");
|
||||
|
||||
free(blob);
|
||||
blob_destroy(blob);
|
||||
ralloc_free(ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog,
|
|||
_mesa_shader_stage_to_string(prog->info.stage), sha1_buf);
|
||||
}
|
||||
|
||||
free(blob);
|
||||
blob_destroy(blob);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue