]> granicus.if.org Git - curl/commitdiff
fix memory leak in case of memory problems
authorDaniel Stenberg <daniel@haxx.se>
Sat, 31 Mar 2007 21:20:16 +0000 (21:20 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 31 Mar 2007 21:20:16 +0000 (21:20 +0000)
CID 16 by coverity.com scan

src/main.c

index cfec4a307c3a722a2356382bb05ed109922173e7..5a953519d391a8f2f137e9bb3532a100374fab60 100644 (file)
@@ -4671,9 +4671,14 @@ static int create_dir_hierarchy(const char *outfile)
   int error;
 
   outdup = strdup(outfile);
+  if(!outdup)
+    return -1;
+
   dirbuildup = malloc(sizeof(char) * strlen(outfile));
-  if(!dirbuildup)
+  if(!dirbuildup) {
+    free(outdup);
     return -1;
+  }
   dirbuildup[0] = '\0';
 
   tempdir = strtok(outdup, DIR_CHAR);