Browse Source

engine: cvar: add null checks as these functions are passed to user's DLL

pull/2/head
Alibek Omarov 5 years ago
parent
commit
ecd675926a
  1. 25
      engine/common/cvar.c

25
engine/common/cvar.c

@ -590,7 +590,16 @@ Cvar_Set @@ -590,7 +590,16 @@ Cvar_Set
*/
void Cvar_Set( const char *var_name, const char *value )
{
convar_t *var = Cvar_FindVar( var_name );
convar_t *var;
if( !var_name )
{
// there is an error in C code if this happens
Con_Printf( "Cvar_Set: passed NULL variable name\n", var_name );
return;
}
var = Cvar_FindVar( var_name );
if( !var )
{
@ -637,6 +646,13 @@ float Cvar_VariableValue( const char *var_name ) @@ -637,6 +646,13 @@ float Cvar_VariableValue( const char *var_name )
{
convar_t *var;
if( !var_name )
{
// there is an error in C code if this happens
Con_Printf( "Cvar_VariableValue: passed NULL variable name\n", var_name );
return 0.0f;
}
var = Cvar_FindVar( var_name );
if( !var ) return 0.0f;
@ -667,6 +683,13 @@ const char *Cvar_VariableString( const char *var_name ) @@ -667,6 +683,13 @@ const char *Cvar_VariableString( const char *var_name )
{
convar_t *var;
if( !var_name )
{
// there is an error in C code if this happens
Con_Printf( "Cvar_VariableString: passed NULL variable name\n", var_name );
return "";
}
var = Cvar_FindVar( var_name );
if( !var ) return "";

Loading…
Cancel
Save