Switch to malloc() for C_SceneEntity::LoadScene()

It used new char[] before, but it seems when the buffer is allocated
using filesystem->ReadFileEx() we should free() the buffer, not delete[]
it. CUtlBuffer also free()s the buffer, so malloc() should be the saner
choice here.
This commit is contained in:
Alexander 'z33ky' Hirsch 2020-06-13 22:35:11 +02:00
parent 77fada1ca2
commit 4d45c32be9

View File

@ -823,10 +823,10 @@ CChoreoScene *C_SceneEntity::LoadScene( const char *filename )
if ( bufsize > 0 ) if ( bufsize > 0 )
{ {
// Definitely in scenes.image // Definitely in scenes.image
pBuffer = new char[ bufsize ]; pBuffer = malloc( bufsize );
if ( !scenefilecache->GetSceneData( filename, (byte *)pBuffer, bufsize ) ) if ( !scenefilecache->GetSceneData( filename, (byte *)pBuffer, bufsize ) )
{ {
delete[] pBuffer; free( pBuffer );
return NULL; return NULL;
} }
@ -866,10 +866,10 @@ CChoreoScene *C_SceneEntity::LoadScene( const char *filename )
if ( bufsize <= 0 ) if ( bufsize <= 0 )
return NULL; return NULL;
pBuffer = new char[ bufsize ]; pBuffer = malloc( bufsize );
if ( !scenefilecache->GetSceneData( filename, (byte *)pBuffer, bufsize ) ) if ( !scenefilecache->GetSceneData( filename, (byte *)pBuffer, bufsize ) )
{ {
delete[] pBuffer; free( pBuffer );
return NULL; return NULL;
} }
@ -897,7 +897,7 @@ CChoreoScene *C_SceneEntity::LoadScene( const char *filename )
} }
#endif #endif
delete[] pBuffer; free( pBuffer );
return pScene; return pScene;
} }
@ -1261,4 +1261,4 @@ void C_SceneEntity::PrefetchAnimBlocks( CChoreoScene *pScene )
return; return;
Msg( "%d of %d animations resident\n", nResident, nChecked ); Msg( "%d of %d animations resident\n", nResident, nChecked );
} }