Add missing sanity checks in ED_ParseEdict() and ED_NewString().

This was reported by maraakate in yquake2 issue #160.
This commit is contained in:
Yamagi Burmeister 2016-12-17 10:55:38 +01:00
parent 8a9b33612a
commit 48a06ef31e

View file

@ -341,6 +341,11 @@ ED_NewString(const char *string)
char *newb, *new_p; char *newb, *new_p;
int i, l; int i, l;
if (!string)
{
return NULL;
}
l = strlen(string) + 1; l = strlen(string) + 1;
newb = gi.TagMalloc(l, TAG_LEVEL); newb = gi.TagMalloc(l, TAG_LEVEL);
@ -450,6 +455,11 @@ ED_ParseEdict(char *data, edict_t *ent)
char keyname[256]; char keyname[256];
const char *com_token; const char *com_token;
if (!ent)
{
return NULL;
}
init = false; init = false;
memset(&st, 0, sizeof(st)); memset(&st, 0, sizeof(st));