don't check safe_malloc() result for NULL
This commit is contained in:
parent
3f8d708bc4
commit
1c73baa8b9
|
|
@ -346,23 +346,17 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
|
||||||
// filename is a full path
|
// filename is a full path
|
||||||
if ( index == -1 ) {
|
if ( index == -1 ) {
|
||||||
strcpy( g_strLoadedFileLocation, filename );
|
strcpy( g_strLoadedFileLocation, filename );
|
||||||
long len;
|
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
f = fopen( filename, "rb" );
|
FILE *f = fopen( filename, "rb" );
|
||||||
if ( f == NULL ) {
|
if ( f == NULL ) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek( f, 0, SEEK_END );
|
fseek( f, 0, SEEK_END );
|
||||||
len = ftell( f );
|
const long len = ftell( f );
|
||||||
rewind( f );
|
rewind( f );
|
||||||
|
|
||||||
*bufferptr = safe_malloc( len + 1 );
|
*bufferptr = safe_malloc( len + 1 );
|
||||||
if ( *bufferptr == NULL ) {
|
|
||||||
fclose( f );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( fread( *bufferptr, 1, len, f ) != (size_t) len ) {
|
if ( fread( *bufferptr, 1, len, f ) != (size_t) len ) {
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
|
@ -389,23 +383,16 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
|
||||||
if ( count == index ) {
|
if ( count == index ) {
|
||||||
strcpy( g_strLoadedFileLocation, tmp );
|
strcpy( g_strLoadedFileLocation, tmp );
|
||||||
|
|
||||||
long len;
|
FILE *f = fopen( tmp, "rb" );
|
||||||
FILE *f;
|
|
||||||
|
|
||||||
f = fopen( tmp, "rb" );
|
|
||||||
if ( f == NULL ) {
|
if ( f == NULL ) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek( f, 0, SEEK_END );
|
fseek( f, 0, SEEK_END );
|
||||||
len = ftell( f );
|
const long len = ftell( f );
|
||||||
rewind( f );
|
rewind( f );
|
||||||
|
|
||||||
*bufferptr = safe_malloc( len + 1 );
|
*bufferptr = safe_malloc( len + 1 );
|
||||||
if ( *bufferptr == NULL ) {
|
|
||||||
fclose( f );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( fread( *bufferptr, 1, len, f ) != (size_t) len ) {
|
if ( fread( *bufferptr, 1, len, f ) != (size_t) len ) {
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user