Repository navigation
Commit 37a21d2
committed
Add worn-slot sanity check to catch stale equipment-slot pointers.
A were-creature's lycanthropy bite can panic the game with
"extract_nobj: object lost": set_ulycn() calls retouch_equipment()
to force-drop gear the new were-form can no longer touch, and the
forced drop reaches freeinv() with a wielded object that is no longer
in invent. The wielded slot (uwep) was left pointing at an object
that had already departed the invent chain on an earlier turn, so
the drop fails its inventory lookup and panics.
The per-turn obj_sanity_check() never caught this because
sanity_check_worn() only validates the invent->slot direction: for
each worn object found in invent, it confirms the matching ufoo
points back to it. A slot pointing the other way, at an object that
has left invent, is never visited and rides undetected until the
downstream freeinv().
Add worn_slot_sanity(), the missing slot->invent check, to report
the stale slot at (or one turn after) the producing action with turn
context, instead of crashing later.
* mkobj.c:
- new worn_slot_sanity() walks the 14 invent-resident worn-slot
globals (uwep..ublindf; ball/chain and the steed saddle are
excluded) and reports any slot whose object is absent from the
invent chain. It compares pointers only, never dereferencing the
possibly-dangling suspect, and dedups per slot so a persistent
stale slot reports once rather than every turn (mirrors
dmonsfree's orphan-warning pattern). Called from
obj_sanity_check() alongside the existing list checks.
* artifact.c:
- call worn_slot_sanity() at the top of retouch_equipment(), under
the same sanity/fuzzer gate, so a slot corrupted earlier in the
same turn is reported immediately before the forced drop turns it
into a panic.
* extern.h:
- declare worn_slot_sanity().1 parent 94b0d12 commit 37a21d2
4 files changed
Lines changed: 61 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5502 | 5502 | | |
5503 | 5503 | | |
5504 | 5504 | | |
| 5505 | + | |
5505 | 5506 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1546 | 1546 | | |
1547 | 1547 | | |
1548 | 1548 | | |
| 1549 | + | |
1549 | 1550 | | |
1550 | 1551 | | |
1551 | 1552 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4735 | 4735 | | |
4736 | 4736 | | |
4737 | 4737 | | |
| 4738 | + | |
| 4739 | + | |
| 4740 | + | |
| 4741 | + | |
| 4742 | + | |
4738 | 4743 | | |
4739 | 4744 | | |
4740 | 4745 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2885 | 2885 | | |
2886 | 2886 | | |
2887 | 2887 | | |
| 2888 | + | |
2888 | 2889 | | |
2889 | 2890 | | |
2890 | 2891 | | |
| |||
2914 | 2915 | | |
2915 | 2916 | | |
2916 | 2917 | | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
2917 | 2971 | | |
2918 | 2972 | | |
2919 | 2973 | | |
| |||
0 commit comments