diff options
Diffstat (limited to 'src/analysis/contents/memory.c')
-rw-r--r-- | src/analysis/contents/memory.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/analysis/contents/memory.c b/src/analysis/contents/memory.c index 9ddc4fa..f80a01a 100644 --- a/src/analysis/contents/memory.c +++ b/src/analysis/contents/memory.c @@ -196,6 +196,7 @@ static void g_memory_content_init(GMemoryContent *content) content->data = NULL; content->length = 0; + content->allocated = false; content->full_desc = strdup("In-memory content"); content->desc = strdup("In-memory content"); @@ -302,8 +303,11 @@ static void g_memory_content_dispose(GMemoryContent *content) static void g_memory_content_finalize(GMemoryContent *content) { - if (content->data != NULL) - free(content->data); + if (content->allocated) + { + if (content->data != NULL) + free(content->data); + } if (content->desc != NULL) free(content->desc); @@ -347,6 +351,7 @@ GBinContent *g_memory_content_new(const bin_t *data, phys_t size) result->data = allocated; result->length = size; + result->allocated = true; return G_BIN_CONTENT(result); @@ -929,6 +934,9 @@ static bool g_memory_content_load(GMemoryContent *content, GObjectStorage *stora { content->data = malloc(length); result = (content->data != NULL); + + content->allocated = true; + } if (result) |