diff -uwr nethack-linux/include/extern.h nethack-thrown-potion-iron-bars-crash-C343-100/include/extern.h --- nethack-linux/include/extern.h 2008-05-26 19:47:02.000000000 +0200 +++ nethack-thrown-potion-iron-bars-crash-C343-100/include/extern.h 2008-12-28 08:55:50.000000000 +0100 @@ -2367,7 +2367,7 @@ E void FDECL(hit, (const char *,struct monst *,const char *)); E void FDECL(miss, (const char *,struct monst *)); E struct monst *FDECL(bhit, (int,int,int,int,int (*)(MONST_P,OBJ_P), - int (*)(OBJ_P,OBJ_P),struct obj *)); + int (*)(OBJ_P,OBJ_P),struct obj *, boolean *)); E struct monst *FDECL(boomhit, (int,int)); E int FDECL(burn_floor_paper, (int,int,BOOLEAN_P,BOOLEAN_P)); E void FDECL(buzz, (int,int,XCHAR_P,XCHAR_P,int,int)); diff -uwr nethack-linux/src/apply.c nethack-thrown-potion-iron-bars-crash-C343-100/src/apply.c --- nethack-linux/src/apply.c 2008-05-26 19:47:02.000000000 +0200 +++ nethack-thrown-potion-iron-bars-crash-C343-100/src/apply.c 2008-12-28 11:03:52.000000000 +0100 @@ -80,7 +80,7 @@ } 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, NULL)) != 0) { obj->ox = u.ux, obj->oy = u.uy; (void) flash_hits_mon(mtmp, obj); } @@ -670,7 +670,7 @@ 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, NULL); if (!mtmp || !haseyes(mtmp->data)) return 1; diff -uwr nethack-linux/src/dokick.c nethack-thrown-potion-iron-bars-crash-C343-100/src/dokick.c --- nethack-linux/src/dokick.c 2008-05-26 19:47:02.000000000 +0200 +++ nethack-thrown-potion-iron-bars-crash-C343-100/src/dokick.c 2008-12-28 11:08:50.000000000 +0100 @@ -553,7 +553,7 @@ mon = bhit(u.dx, u.dy, range, KICKED_WEAPON, (int FDECL((*),(MONST_P,OBJ_P)))0, (int FDECL((*),(OBJ_P,OBJ_P)))0, - kickobj); + kickobj, NULL); if(mon) { if (mon->isshk && diff -uwr nethack-linux/src/dothrow.c nethack-thrown-potion-iron-bars-crash-C343-100/src/dothrow.c --- nethack-linux/src/dothrow.c 2008-05-26 19:47:02.000000000 +0200 +++ nethack-thrown-potion-iron-bars-crash-C343-100/src/dothrow.c 2008-12-28 18:06:30.000000000 +0100 @@ -980,14 +980,17 @@ if (Underwater) range = 1; + boolean obj_destroyed = FALSE; mon = bhit(u.dx, u.dy, range, THROWN_WEAPON, (int FDECL((*),(MONST_P,OBJ_P)))0, (int FDECL((*),(OBJ_P,OBJ_P)))0, - obj); + obj, &obj_destroyed); /* have to do this after bhit() so u.ux & u.uy are correct */ if(Is_airlevel(&u.uz) || Levitation) hurtle(-u.dx, -u.dy, urange, TRUE); + + if (obj_destroyed) return; /* fixes C343-100 */ } if (mon) { @@ -1748,7 +1751,7 @@ mon = bhit(u.dx, u.dy, range, THROWN_WEAPON, (int FDECL((*),(MONST_P,OBJ_P)))0, (int FDECL((*),(OBJ_P,OBJ_P)))0, - obj); + obj, NULL); if(mon) { if (ghitm(mon, obj)) /* was it caught? */ return 1; diff -uwr nethack-linux/src/zap.c nethack-thrown-potion-iron-bars-crash-C343-100/src/zap.c --- nethack-linux/src/zap.c 2008-05-26 19:47:02.000000000 +0200 +++ nethack-thrown-potion-iron-bars-crash-C343-100/src/zap.c 2008-12-28 18:06:07.000000000 +0100 @@ -2467,7 +2467,7 @@ } else if (u.dz) { disclose = zap_updown(obj); } else { - (void) bhit(u.dx,u.dy, rn1(8,6),ZAPPED_WAND, bhitm,bhito, obj); + (void) bhit(u.dx,u.dy, rn1(8,6),ZAPPED_WAND, bhitm,bhito, obj, NULL); } /* give a clue if obj_zapped */ if (obj_zapped) @@ -2615,16 +2615,18 @@ * one is revealed for a weapon, but if not a weapon is left up to fhitm(). */ struct monst * -bhit(ddx,ddy,range,weapon,fhitm,fhito,obj) +bhit(ddx,ddy,range,weapon,fhitm,fhito,obj,obj_destroyed) register int ddx,ddy,range; /* direction and range */ int weapon; /* see values in hack.h */ int FDECL((*fhitm), (MONST_P, OBJ_P)), /* fns called when mon/obj hit */ FDECL((*fhito), (OBJ_P, OBJ_P)); struct obj *obj; /* object tossed/used */ +boolean *obj_destroyed; /* has object been deallocated? Pointer to boolean, may be NULL */ { struct monst *mtmp; uchar typ; boolean shopdoor = FALSE, point_blank = TRUE; + if (obj_destroyed) { *obj_destroyed = FALSE; } if (weapon == KICKED_WEAPON) { /* object starts one square in front of player */ @@ -2668,6 +2670,7 @@ hits_bars(&obj, x - ddx, y - ddy, point_blank ? 0 : !rn2(5), 1)) { /* caveat: obj might now be null... */ + if (obj == NULL && obj_destroyed) { *obj_destroyed = TRUE; } bhitpos.x -= ddx; bhitpos.y -= ddy; break;