progs/redbook: Fix memory leaks on error paths.

This commit is contained in:
Vinson Lee 2010-02-17 01:57:14 -08:00
parent 41b19c279a
commit 7eaf33ad03
3 changed files with 3 additions and 0 deletions

View File

@ -97,6 +97,7 @@ readImage( const char* filename, GLsizei* width, GLsizei *height )
pixels = (GLubyte *) malloc( n * sizeof( GLubyte ));
if ( !pixels ) {
fprintf( stderr, "Unable to malloc() bytes for pixels\n" );
fclose( infile );
return NULL;
}

View File

@ -102,6 +102,7 @@ readImage( const char* filename, GLsizei* width, GLsizei *height )
pixels = (GLubyte *) malloc( n * sizeof( GLubyte ));
if ( !pixels ) {
fprintf( stderr, "Unable to malloc() bytes for pixels\n" );
fclose( infile );
return NULL;
}

View File

@ -97,6 +97,7 @@ readImage( const char* filename, GLsizei* width, GLsizei *height )
pixels = (GLubyte *) malloc( n * sizeof( GLubyte ));
if ( !pixels ) {
fprintf( stderr, "Unable to malloc() bytes for pixels\n" );
fclose( infile );
return NULL;
}