mirror of
https://github.com/reactos/reactos.git
synced 2024-10-01 23:14:53 +00:00
- Various resource fixes (unclosed files, unchecked memory allocations, missing destructor, not freed memory)
- Patch by Russell with some modifications by myself See issue #4662 for more details. svn path=/trunk/; revision=43347
This commit is contained in:
parent
ef0f96e223
commit
ce47d4b62f
|
@ -203,6 +203,7 @@ BOOL ProcessXML (const char* filename, struct Category* Root)
|
||||||
if(!XML_Parse(parser, buffer, len, done))
|
if(!XML_Parse(parser, buffer, len, done))
|
||||||
{
|
{
|
||||||
MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
|
MessageBoxW(0,Strings[IDS_XMLERROR_2],0,0);
|
||||||
|
fclose(file);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -829,7 +829,11 @@ struct class *add_class (type, name)
|
||||||
user_class_hash = new_hash ();
|
user_class_hash = new_hash ();
|
||||||
|
|
||||||
if (!tname || !class || !vendor_class_hash || !user_class_hash)
|
if (!tname || !class || !vendor_class_hash || !user_class_hash)
|
||||||
|
{
|
||||||
|
if (tname != NULL)
|
||||||
|
free(tname);
|
||||||
return (struct class *)0;
|
return (struct class *)0;
|
||||||
|
}
|
||||||
|
|
||||||
memset (class, 0, sizeof *class);
|
memset (class, 0, sizeof *class);
|
||||||
strcpy (tname, name);
|
strcpy (tname, name);
|
||||||
|
|
|
@ -50,6 +50,10 @@ int main(int argc, char *argv[])
|
||||||
if (!DependFileData || !NewDependFileData)
|
if (!DependFileData || !NewDependFileData)
|
||||||
{
|
{
|
||||||
printf("deptool: Out of memory!\n");
|
printf("deptool: Out of memory!\n");
|
||||||
|
if (DependFileData != NULL)
|
||||||
|
free(DependFileData);
|
||||||
|
if (NewDependFileData != NULL)
|
||||||
|
free(NewDependFileData);
|
||||||
fclose(DependFile);
|
fclose(DependFile);
|
||||||
return ERROR_OUTOFMEMORY;
|
return ERROR_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +65,8 @@ int main(int argc, char *argv[])
|
||||||
if (ferror(DependFile))
|
if (ferror(DependFile))
|
||||||
{
|
{
|
||||||
printf("deptool: Dependency file read error.\n");
|
printf("deptool: Dependency file read error.\n");
|
||||||
|
free(DependFileData);
|
||||||
|
free(NewDependFileData);
|
||||||
fclose(DependFile);
|
fclose(DependFile);
|
||||||
return ERROR_READERROR;
|
return ERROR_READERROR;
|
||||||
}
|
}
|
||||||
|
@ -121,9 +127,13 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf("deptool: Dependency file write error.\n");
|
printf("deptool: Dependency file write error.\n");
|
||||||
fclose(DependFile);
|
fclose(DependFile);
|
||||||
|
free(DependFileData);
|
||||||
|
free(NewDependFileData);
|
||||||
return ERROR_WRITEERROR;
|
return ERROR_WRITEERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(DependFile);
|
fclose(DependFile);
|
||||||
|
free(DependFileData);
|
||||||
|
free(NewDependFileData);
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,14 +236,22 @@ write_h (int build, char *buildstr, long revno)
|
||||||
char* orig;
|
char* orig;
|
||||||
|
|
||||||
orig = (char *) malloc(length);
|
orig = (char *) malloc(length);
|
||||||
|
if (orig == NULL)
|
||||||
|
{
|
||||||
|
fclose(h);
|
||||||
|
free(s1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
fseek(h, 0, SEEK_SET);
|
fseek(h, 0, SEEK_SET);
|
||||||
fread(orig, 1, length, h);
|
fread(orig, 1, length, h);
|
||||||
if (memcmp(s1, orig, length) == 0)
|
if (memcmp(s1, orig, length) == 0)
|
||||||
{
|
{
|
||||||
fclose(h);
|
fclose(h);
|
||||||
free(s1);
|
free(s1);
|
||||||
|
free(orig);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
free(orig);
|
||||||
}
|
}
|
||||||
fclose(h);
|
fclose(h);
|
||||||
}
|
}
|
||||||
|
@ -259,7 +267,7 @@ write_h (int build, char *buildstr, long revno)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fwrite(s1, 1, strlen(s1), h);
|
fwrite(s1, 1, strlen(s1), h);
|
||||||
fclose (h);
|
fclose(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1259,7 +1259,10 @@ static void pass(void)
|
||||||
size = ftell(file);
|
size = ftell(file);
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
if (size == 0 || (size % 2048))
|
if (size == 0 || (size % 2048))
|
||||||
|
{
|
||||||
|
fclose(file);
|
||||||
error_exit("Invalid boot image size (%lu bytes)\n", size);
|
error_exit("Invalid boot image size (%lu bytes)\n", size);
|
||||||
|
}
|
||||||
boot_image_size = size / 512;
|
boot_image_size = size / 512;
|
||||||
while (size > 0)
|
while (size > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,15 +44,18 @@ write_if_change(char* outbuf, char* filename)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to read data\n");
|
fprintf(stderr, "Failed to read data\n");
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
free(cmpbuf);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
if (end == strlen(outbuf) && memcmp(cmpbuf, outbuf, end) == 0)
|
if (end == strlen(outbuf) && memcmp(cmpbuf, outbuf, end) == 0)
|
||||||
{
|
{
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
free(cmpbuf);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
free(cmpbuf);
|
||||||
out = fopen(filename, "wb");
|
out = fopen(filename, "wb");
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -455,6 +455,7 @@ protected:
|
||||||
void ParseToolsets ( const Project& project, const XMLElement& node );
|
void ParseToolsets ( const Project& project, const XMLElement& node );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~ToolsetDirective() { }
|
||||||
bool IsEnabled () const;
|
bool IsEnabled () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -469,6 +470,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CompilerDirective (): enabled ( true ) { }
|
CompilerDirective (): enabled ( true ) { }
|
||||||
|
virtual ~CompilerDirective() { }
|
||||||
void SetCompiler ( CompilerType compiler );
|
void SetCompiler ( CompilerType compiler );
|
||||||
void UnsetCompiler ( CompilerType compiler );
|
void UnsetCompiler ( CompilerType compiler );
|
||||||
void SetAllCompilers ();
|
void SetAllCompilers ();
|
||||||
|
|
|
@ -88,7 +88,13 @@ int main( int argc, char **argv ) {
|
||||||
if( new_f ) continue;
|
if( new_f ) continue;
|
||||||
|
|
||||||
new_f = (stub *)malloc( sizeof(stub) );
|
new_f = (stub *)malloc( sizeof(stub) );
|
||||||
if( !new_f ) {fprintf( stderr, "Out of memory\n" ); return 1;}
|
if( !new_f )
|
||||||
|
{
|
||||||
|
fprintf( stderr, "Out of memory\n" );
|
||||||
|
fclose( out );
|
||||||
|
pclose( make_f );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
new_f->name = strdup( line );
|
new_f->name = strdup( line );
|
||||||
new_f->next = functions;
|
new_f->next = functions;
|
||||||
|
@ -129,7 +135,14 @@ int main( int argc, char **argv ) {
|
||||||
if( new_f ) continue;
|
if( new_f ) continue;
|
||||||
|
|
||||||
new_f = (stub *)malloc( sizeof(stub) );
|
new_f = (stub *)malloc( sizeof(stub) );
|
||||||
if( !new_f ) {fprintf( stderr, "Out of memory\n" ); return 1;}
|
if( !new_f )
|
||||||
|
{
|
||||||
|
fprintf( stderr, "Out of memory\n" );
|
||||||
|
fclose( out );
|
||||||
|
pclose( make_f );
|
||||||
|
pclose( nm_f );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
new_f->name = strdup( import_sign + 1 );
|
new_f->name = strdup( import_sign + 1 );
|
||||||
new_f->origin = origin;
|
new_f->origin = origin;
|
||||||
|
@ -137,7 +150,7 @@ int main( int argc, char **argv ) {
|
||||||
imports = new_f;
|
imports = new_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose( nm_f );
|
pclose( nm_f );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now we have a list of unique functions and a list of imports,
|
/* Now we have a list of unique functions and a list of imports,
|
||||||
|
@ -152,6 +165,6 @@ int main( int argc, char **argv ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose( out );
|
fclose( out );
|
||||||
|
pclose( make_f );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue