From d0fb4ff187c8bb6a92724d28e76438c887344cfc Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Tue, 21 Apr 2020 21:02:32 +0200 Subject: Fix memory leak in cc4group.getFullName --- src/cc4group.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cc4group.c b/src/cc4group.c index da1ead4..7f822d9 100644 --- a/src/cc4group.c +++ b/src/cc4group.c @@ -3344,17 +3344,17 @@ static char* cc4group_getFullName(const CC4Group* const this) child = child->parent; } + char* result = NULL; if(!child->path) { - GroupListDestroy(groups); - return NULL; + goto ret; } len += strlen(child->path) + 1; - char* result = malloc(sizeof(char) * len); + result = malloc(sizeof(char) * len); if(result == NULL) { - return NULL; + goto ret; } strcpy(result, child->path); @@ -3364,6 +3364,8 @@ static char* cc4group_getFullName(const CC4Group* const this) strcat(result, group->value->pathInParent); } +ret: + GroupListDestroy(groups); return result; } -- cgit v1.2.3-54-g00ecf