fix K4318

Reported by paxed. A potion of oil, that was already in the midst of exploding,
got picked up through spot_effects(), which led to it merging with
another potion of oil and the freeing of the original obj.

The original obj pointer was still held by breakobj(), and breakobj()
proceeded to delete the obj (again).

Function nesting:

 1    spelleffects()
 2     -> weffects()
 3      -> bhit()
 4       -> bhitpile()
 5        -> bhito(obj ...)
 6         -> hero_breaks(obj ...)
 7          -> breakobj(obj ...)
 8           -> explode_oil(obj ...)
 9            -> splatter_burning_oil()
10             -> explode()
11              -> zap_over_floor()
12               -> melt_ice()
13                -> spot_effects()
14                 -> pickup()
15                  -> pickup_object(obj ...)
16                   -> pick_obj(obj ...)
17                    -> addinv(obj ...)
18                     -> addinv_core0(obj ...)
19                      -> merged(obj ...)
20                       -> obfree(obj ...)
21                        -> dealloc_obj(obj ...)

 8           -> delobj(obj ...)
 9            -> delobj_core(obj ...)
10             -> obfree(obj ...)
11              -> dealloc_obj(obj ...)
12               -> impossible("obj already deleted)

This marks the exploding potion with LOST_EXPLODING, so that it won't
get picked up, or merged with another object during the long
sequence of functions, and that should take care of 15-21 above.
This commit is contained in:
nhmall
2025-01-12 13:50:25 -05:00
parent a8be021913
commit bee21e3447
4 changed files with 13 additions and 6 deletions

View File

@@ -469,10 +469,12 @@ struct obj {
#define POTHIT_OTHER_THROW 3 /* propelled by some other means [scatter()] */
/* tracking how an item left your inventory via how_lost field */
#define LOST_NONE 0 /* still in inventory, or method not covered below */
#define LOST_THROWN 1 /* thrown or fired by the hero */
#define LOST_DROPPED 2 /* dropped or tipped out of a container by the hero */
#define LOST_STOLEN 3 /* stolen from hero's inventory by a monster */
#define LOST_NONE 0 /* still in inventory, or method not covered below */
#define LOST_THROWN 1 /* thrown or fired by the hero */
#define LOST_DROPPED 2 /* dropped or tipped out of a container by the hero */
#define LOST_STOLEN 3 /* stolen from hero's inventory by a monster */
#define LOSTOVERRIDEMASK 0x3
#define LOST_EXPLODING 4 /* the object is exploding (i.e. POT_OIL) */
/* tracking how a name got acquired by an object in named_how field */
#define NAMED_PLAIN 0 /* nothing special, typical naming */