Browse code

another error path leak

Tomasz Kojm authored on 2009/10/28 05:06:37
Showing 1 changed files
... ...
@@ -998,15 +998,22 @@ static int sigtool_scandir (const char *dirname, int hex_output)
998 998
 
999 999
 				/* generate the temporary directory */
1000 1000
 				dir = cli_gentemp (tmpdir);
1001
+				if(!dir) {
1002
+				    printf("cli_gentemp() failed\n");
1003
+				    closedir (dd);
1004
+				    return -1;
1005
+				}
1001 1006
 				if (mkdir (dir, 0700)) {
1002 1007
 				    printf ("Can't create temporary directory %s\n", dir);
1003 1008
 				    closedir (dd);
1009
+				    free(dir);
1004 1010
 				    return CL_ETMPDIR;
1005 1011
 				}
1006 1012
 
1007 1013
 				if ((desc = open (fname, O_RDONLY)) == -1) {
1008 1014
 				    printf ("Can't open file %s\n", fname);
1009 1015
 				    closedir (dd);
1016
+				    free(dir);
1010 1017
 				    return 1;
1011 1018
 				}
1012 1019