Skip to content

Commit

Permalink
All Def_Get routines should check for passed null ptrs.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij committed Jul 28, 2006
1 parent f9835fc commit f682b85
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions doomsday/engine/portable/src/def_main.c
Expand Up @@ -224,6 +224,9 @@ int Def_GetSpriteNum(char *name)
{
int i;

if(!name || !name[0])
return -1;

for(i = 0; i < count_sprnames.num; i++)
if(!stricmp(sprnames[i].name, name))
return i;
Expand All @@ -248,6 +251,9 @@ int Def_GetMobjNumForName(char *name)
{
int i;

if(!name || !name[0])
return -1;

for(i = defs.count.mobjs.num -1; i >= 0; --i)
if(!stricmp(defs.mobjs[i].name, name))
return i;
Expand All @@ -259,6 +265,9 @@ int Def_GetStateNum(char *id)
{
int i;

if(!id || !id[0])
return -1;

for(i = 0; i < defs.count.states.num; i++)
if(!strcmp(defs.states[i].id, id))
return i;
Expand Down Expand Up @@ -301,6 +310,9 @@ int Def_GetSoundNumForName(char *name)
{
int i;

if(!name || !name[0])
return -1;

for(i = 0; i < defs.count.sounds.num; i++)
if(!stricmp(defs.sounds[i].name, name))
return i;
Expand Down Expand Up @@ -332,6 +344,9 @@ acfnptr_t Def_GetActionPtr(char *name)
// action functions.
actionlink_t *link = (void *) gx.Get(DD_ACTION_LINK);

if(!name || !name[0])
return 0;

if(!link)
{
Con_Error("GetActionPtr: Game DLL doesn't have an action "
Expand All @@ -354,6 +369,9 @@ ded_mapinfo_t *Def_GetMapInfo(char *map_id)
{
int i;

if(!map_id || !map_id[0])
return 0;

for(i = defs.count.mapinfo.num - 1; i >= 0; i--)
if(!stricmp(defs.mapinfo[i].id, map_id))
return defs.mapinfo + i;
Expand Down Expand Up @@ -408,6 +426,9 @@ ded_xgclass_t *Def_GetXGClass(char *name)
ded_xgclass_t *def;
int i;

if(!name || !name[0])
return 0;

for(i = defs.count.xgclasses.num - 1, def = defs.xgclasses + i;
i >= 0; i--, def--)
{
Expand Down

0 comments on commit f682b85

Please sign in to comment.