From 4073b88ed740e6edde6c88ad12c0c03a368a9446 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 27 May 2020 22:33:50 +0200 Subject: [PATCH] fix realloc properly --- client/src/ui.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/ui.c b/client/src/ui.c index 5764e63df..24eac6a16 100644 --- a/client/src/ui.c +++ b/client/src/ui.c @@ -99,11 +99,12 @@ int searchHomeFilePath(char **foundpath, const char *subdir, const char *filenam } if (subdir != NULL) { pathlen += strlen(subdir); - path = realloc(path, pathlen * sizeof(char)); - if (path == NULL) { + char *tmp = realloc(path, pathlen * sizeof(char)); + if (tmp == NULL) { free(path); return PM3_EMALLOC; } + path = tmp; strcat(path, subdir); #ifdef _WIN32