[gamecode] Check entity_var is valid before display

Even NUM_FOR_BAD_EDICT will have a bad day if the edict pointer is
invalid, so make sure that the entity pointer is valid (within the edict
area AND a multiple of edict size).
This commit is contained in:
Bill Currie 2021-12-27 13:47:55 +09:00
parent 95991e0d77
commit 6368791d2b

View file

@ -1252,7 +1252,9 @@ pr_debug_entity_view (qfot_type_t *type, pr_type_t *value, void *_data)
progs_t *pr = data->pr;
dstring_t *dstr = data->dstr;
if (pr->pr_edicts) {
if (pr->pr_edicts && value->entity_var >= 0
&& value->entity_var < pr->max_edicts
&& !(value->entity_var % pr->pr_edict_size)) {
edict_t *edict = PROG_TO_EDICT (pr, value->entity_var);
if (edict) {
dasprintf (dstr, "entity %d", NUM_FOR_BAD_EDICT (pr, edict));