avoid crash when thrown potion hits bars before a monster
From a bug report. <Someone> as slashem-Bugs-883643 on 1/24/2004. To avoid using the possibly invalid object pointer after calling bhit(), changed as suggested to add another level of indirection allowing bhit to null the object pointer before returning. Callers that are affected update their object pointers after bhit returns.
This commit is contained in:
@@ -79,7 +79,7 @@ use_camera(obj)
|
||||
} else if ((mtmp = bhit(u.dx, u.dy, COLNO, FLASHED_LIGHT,
|
||||
(int FDECL((*),(MONST_P,OBJ_P)))0,
|
||||
(int FDECL((*),(OBJ_P,OBJ_P)))0,
|
||||
obj)) != 0) {
|
||||
&obj)) != 0) {
|
||||
obj->ox = u.ux, obj->oy = u.uy;
|
||||
(void) flash_hits_mon(mtmp, obj);
|
||||
}
|
||||
@@ -749,7 +749,7 @@ struct obj *obj;
|
||||
mtmp = bhit(u.dx, u.dy, COLNO, INVIS_BEAM,
|
||||
(int FDECL((*),(MONST_P,OBJ_P)))0,
|
||||
(int FDECL((*),(OBJ_P,OBJ_P)))0,
|
||||
obj);
|
||||
&obj);
|
||||
if (!mtmp || !haseyes(mtmp->data))
|
||||
return 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user