summaryrefslogtreecommitdiff
path: root/src/analysis/contents/memory.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-01-29 19:16:37 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-01-29 19:16:37 (GMT)
commit8cbc874ef01f3d161d4ca253167d8f80e689c814 (patch)
tree2849e7f5af3915a94d8fb0b766f6b7c8ad1817e7 /src/analysis/contents/memory.c
parent0507bdb3b56083c8e8b011fc3d4c16fed2700340 (diff)
Do not allocate memory for file mmap()'ed contents.
Diffstat (limited to 'src/analysis/contents/memory.c')
-rw-r--r--src/analysis/contents/memory.c12
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)