From 5796c7b1322375da0fa15620ca1a9c825df0ab01 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 31 Mar 2007 21:20:16 +0000 Subject: [PATCH] fix memory leak in case of memory problems CID 16 by coverity.com scan --- src/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index cfec4a307..5a953519d 100644 --- a/src/main.c +++ b/src/main.c @@ -4671,9 +4671,14 @@ static int create_dir_hierarchy(const char *outfile) int error; outdup = strdup(outfile); - dirbuildup = malloc(sizeof(char) * strlen(outfile)); - if(!dirbuildup) + if(!outdup) return -1; + + dirbuildup = malloc(sizeof(char) * strlen(outfile)); + if(!dirbuildup) { + free(outdup); + return -1; + } dirbuildup[0] = '\0'; tempdir = strtok(outdup, DIR_CHAR);