Index: base/applications/downloader/xml.c =================================================================== --- base/applications/downloader/xml.c (revision 41782) +++ base/applications/downloader/xml.c (working copy) @@ -203,6 +203,9 @@ if(!XML_Parse(parser, buffer, len, done)) { MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0); + + fclose(file); + return FALSE; } } Index: base/services/dhcp/memory.c =================================================================== --- base/services/dhcp/memory.c (revision 41782) +++ base/services/dhcp/memory.c (working copy) @@ -829,7 +829,12 @@ user_class_hash = new_hash (); if (!tname || !class || !vendor_class_hash || !user_class_hash) + { + if (tname != NULL) + free(tname); + return (struct class *)0; + } memset (class, 0, sizeof *class); strcpy (tname, name); Index: boot/freeldr/tools/deptool.c =================================================================== --- boot/freeldr/tools/deptool.c (revision 41782) +++ boot/freeldr/tools/deptool.c (working copy) @@ -50,6 +50,13 @@ if (!DependFileData || !NewDependFileData) { printf("deptool: Out of memory!\n"); + + if (DependFileData) + free(DependFileData); + + if (NewDependFileData) + free(NewDependFileData); + fclose(DependFile); return ERROR_OUTOFMEMORY; } @@ -61,6 +68,10 @@ if (ferror(DependFile)) { printf("deptool: Dependency file read error.\n"); + + free(DependFileData); + free(NewDependFileData); + fclose(DependFile); return ERROR_READERROR; } @@ -120,10 +131,17 @@ if (ferror(DependFile)) { printf("deptool: Dependency file write error.\n"); + + free(DependFileData); + free(NewDependFileData); + fclose(DependFile); return ERROR_WRITEERROR; } + free(DependFileData); + free(NewDependFileData); + fclose(DependFile); return ERROR_SUCCESS; } Index: tools/buildno/buildno.cpp =================================================================== --- tools/buildno/buildno.cpp (revision 41782) +++ tools/buildno/buildno.cpp (working copy) @@ -236,14 +236,25 @@ char* orig; orig = (char *) malloc(length); + + if (orig == NULL) + { + fclose(h); + free(s1); + return; + } + fseek(h, 0, SEEK_SET); fread(orig, 1, length, h); if (memcmp(s1, orig, length) == 0) { fclose(h); free(s1); + free(orig); return; } + + free(orig); } fclose(h); } @@ -259,6 +270,8 @@ return; } fwrite(s1, 1, strlen(s1), h); + + free(s1); fclose (h); } Index: tools/cdmake/cdmake.c =================================================================== --- tools/cdmake/cdmake.c (revision 41782) +++ tools/cdmake/cdmake.c (working copy) @@ -1259,7 +1259,10 @@ size = ftell(file); fseek(file, 0, SEEK_SET); if (size == 0 || (size % 2048)) + { + fclose(file); error_exit("Invalid boot image size (%lu bytes)\n", size); + } boot_image_size = size / 512; while (size > 0) { @@ -1278,7 +1281,6 @@ cd.offset += n % SECTOR_SIZE; size -= n; } - fclose(file); // fill_sector(); } Index: tools/mkconfig.c =================================================================== --- tools/mkconfig.c (revision 41782) +++ tools/mkconfig.c (working copy) @@ -44,11 +44,13 @@ { fprintf(stderr, "Failed to read data\n"); fclose(out); + free(cmpbuf); return(1); } if (end == strlen(outbuf) && memcmp(cmpbuf, outbuf, end) == 0) { fclose(out); + free(cmpbuf); return(0); } @@ -57,6 +59,7 @@ if (out == NULL) { fprintf(stderr, "Unable to create output file\n"); + free(cmpbuf); return(1); } @@ -64,10 +67,12 @@ if (strlen(outbuf) != stat) { fprintf(stderr, "Unable to write output file\n"); + free(cmpbuf); fclose(out); return(1); } fclose(out); + free(cmpbuf); return(0); } Index: tools/rbuild/rbuild.h =================================================================== --- tools/rbuild/rbuild.h (revision 41782) +++ tools/rbuild/rbuild.h (working copy) @@ -454,6 +454,7 @@ void ParseToolsets ( const Project& project, const XMLElement& node ); public: + virtual ~ToolsetDirective() { } bool IsEnabled () const; }; @@ -468,6 +469,7 @@ public: CompilerDirective (): enabled ( true ) { } + virtual ~CompilerDirective() { } void SetCompiler ( CompilerType compiler ); void UnsetCompiler ( CompilerType compiler ); void SetAllCompilers (); Index: tools/rsym/log2lines.c =================================================================== --- tools/rsym/log2lines.c (revision 41782) +++ tools/rsym/log2lines.c (working copy) @@ -358,6 +358,7 @@ { if (opt_verbose) fprintf(stderr, "get_ImageBase %s, read error IMAGE_FILE_HEADER (%s)\n", fname, strerror(errno)); + fclose(fr); return 4; } Index: tools/stubgen.c =================================================================== --- tools/stubgen.c (revision 41782) +++ tools/stubgen.c (working copy) @@ -88,7 +88,13 @@ if( new_f ) continue; new_f = (stub *)malloc( sizeof(stub) ); - if( !new_f ) {fprintf( stderr, "Out of memory\n" ); return 1;} + if( !new_f ) + { + fclose(out); + fclose(make_f); + fprintf( stderr, "Out of memory\n" ); + return 1; + } new_f->name = strdup( line ); new_f->next = functions; @@ -129,7 +135,14 @@ if( new_f ) continue; new_f = (stub *)malloc( sizeof(stub) ); - if( !new_f ) {fprintf( stderr, "Out of memory\n" ); return 1;} + if( !new_f ) + { + pclose(nm_f); + fclose(out); + fclose(make_f); + fprintf( stderr, "Out of memory\n" ); + return 1; + } new_f->name = strdup( import_sign + 1 ); new_f->origin = origin; @@ -137,7 +150,7 @@ imports = new_f; } - fclose( nm_f ); + pclose( nm_f ); } /* Now we have a list of unique functions and a list of imports, @@ -151,6 +164,7 @@ } } + fclose(make_f); fclose( out ); return 0;