Added missing malloc failure checks

This commit is contained in:
Landon Curt Noll
2021-02-04 15:28:51 -08:00
parent 229345ade8
commit 8b7e01f426
3 changed files with 18 additions and 2 deletions

8
obj.c
View File

@@ -571,9 +571,13 @@ defineobject(char *name, int indices[], int count)
}
oap = (OBJECTACTIONS *) malloc(objectactionsize(count));
if (oap == NULL) {
math_error("Cannot allocate object type #0");
/*NOTREACHED*/
}
name = addstr(hp, name);
if ((oap == NULL) || (name == NULL)) {
math_error("Cannot allocate object type");
if (name == NULL) {
math_error("Cannot allocate object type #1");
/*NOTREACHED*/
}
oap->oa_count = count;