Browse Source

SV_LoadProgs: Fixed potential memory leak if function failed (#46)

SV_LoadProgs: Fixed potential memory leak if function failed
pull/2/head
Jonathan Poncelet 6 years ago committed by Alibek Omarov
parent
commit
d14ce5ac39
  1. 11
      engine/server/sv_game.c

11
engine/server/sv_game.c

@ -5026,8 +5026,13 @@ qboolean SV_LoadProgs( const char *name ) @@ -5026,8 +5026,13 @@ qboolean SV_LoadProgs( const char *name )
svgame.pmove = &gpMove;
svgame.globals = &gpGlobals;
svgame.mempool = Mem_AllocPool( "Server Edicts Zone" );
svgame.hInstance = COM_LoadLibrary( name, true, false );
if( !svgame.hInstance ) return false;
if( !svgame.hInstance )
{
Mem_FreePool(&svgame.mempool);
return false;
}
// make sure what new dll functions is cleared
memset( &svgame.dllFuncs2, 0, sizeof( svgame.dllFuncs2 ));
@ -5047,6 +5052,7 @@ qboolean SV_LoadProgs( const char *name ) @@ -5047,6 +5052,7 @@ qboolean SV_LoadProgs( const char *name )
COM_FreeLibrary( svgame.hInstance );
Con_Printf( S_ERROR "SV_LoadProgs: failed to get address of GetEntityAPI proc\n" );
svgame.hInstance = NULL;
Mem_FreePool(&svgame.mempool);
return false;
}
@ -5057,6 +5063,7 @@ qboolean SV_LoadProgs( const char *name ) @@ -5057,6 +5063,7 @@ qboolean SV_LoadProgs( const char *name )
COM_FreeLibrary( svgame.hInstance );
Con_Printf( S_ERROR "SV_LoadProgs: failed to get address of GiveFnptrsToDll proc\n" );
svgame.hInstance = NULL;
Mem_FreePool(&svgame.mempool);
return false;
}
@ -5089,6 +5096,7 @@ qboolean SV_LoadProgs( const char *name ) @@ -5089,6 +5096,7 @@ qboolean SV_LoadProgs( const char *name )
COM_FreeLibrary( svgame.hInstance );
Con_Printf( S_ERROR "SV_LoadProgs: couldn't get entity API\n" );
svgame.hInstance = NULL;
Mem_FreePool(&svgame.mempool);
return false;
}
}
@ -5099,6 +5107,7 @@ qboolean SV_LoadProgs( const char *name ) @@ -5099,6 +5107,7 @@ qboolean SV_LoadProgs( const char *name )
COM_FreeLibrary( svgame.hInstance );
Con_Printf( S_ERROR "SV_LoadProgs: couldn't get entity API\n" );
svgame.hInstance = NULL;
Mem_FreePool(&svgame.mempool);
return false;
}

Loading…
Cancel
Save