From f5c99653dd12edc078df3246eb40b9f06e17778e Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Sat, 20 Apr 2019 02:12:53 +0200 Subject: Fix memory leak in cc4group_createFile (and also a possible but really unlikely to happen memory leak in an error case in cc4group_createDirectory) --- src/cc4group.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc4group.c b/src/cc4group.c index 724a8b5..2b5a6b4 100644 --- a/src/cc4group.c +++ b/src/cc4group.c @@ -2144,7 +2144,6 @@ static C4GroupEntryData* cc4group_createEntry(CC4Group* const this, const char* entry.data = NULL; entry.memoryManagement = cc4group.MemoryManagement.Reference; - entry.children = GroupEntryListNew(); C4GroupEntryCore_init(&entry.core); C4GroupEntryCore_setFileName(&entry.core, targetName); @@ -2166,6 +2165,7 @@ static bool cc4group_createDirectory(CC4Group* const this, const char* const pat return false; } + C4GroupHeader* header = malloc(sizeof(C4GroupHeader)); if(header == NULL) @@ -2174,6 +2174,8 @@ static bool cc4group_createDirectory(CC4Group* const this, const char* const pat return NULL; } + entry->children = GroupEntryListNew(); + C4GroupHeader_init(header); C4GroupHeader_setOfficial(header, C4GroupHeader_isOfficial(entry->parent->header)); C4GroupHeader_setMaker(header, entry->parent->header->Maker); -- cgit v1.2.3-54-g00ecf