Commit Graph
7 Commits
Author SHA1 Message Date
Mika Kuoppala 4669676fc0 src/weapon: Avoid touch_petrifies with invalid corpsenm
Filter out unset (-1) corpsenm before calling touch_petrifies.
While here, cleanup the oselect by doing excluding loop
and use can_touch_safely for filtering (suggested by entrez).
2024-01-06 12:06:56 -08:00
Mika Kuoppala 83fba62152 src/uhitm: Avoid touch_petrifies with invalid corpsenm
Before checking with touch_petrifies, check that corpsenm
is valid (>= LOW_PM)
2024-01-06 12:06:55 -08:00
Mika Kuoppala c4d3ca00ce src/muse: Avoid touch_petrifies check if bad corpsenm
EGGs can have non permanent monster based corpsenm assigned
(-1). Before doing the touch_petrifies check, make sure
that we have valid corpsenm.
2024-01-06 12:06:55 -08:00
Mika Kuoppala 4f15e134fc src/mon: Avoid addressing with invalid corpsenm in mstoning
corpsenm can be -1 (for EGGs and TINs) so touch_petrifies
using this as index would point to bad entry.

Fix this by making mstoning as helper function and bailing
out early if corpsenm <= LOW_PM (while keeping MEDUSA as is)
2024-01-06 12:06:54 -08:00
Mika Kuoppala 6a085955ea src/eat: Check for valid corpsenm before checking is_rider
corpsenm can be -1 so limit checking is_rider with only
>= LOW_PM corpse numbers.
2024-01-06 12:06:54 -08:00
Mika Kuoppala 5cfa4cd9f6 src/dog: Fix TIN or EGG based corpsenm
TIN or EGG can have the corpsenm not assigned into a
proper monster and instead have an value of -1.

Take this into account in assigning the monster (fptr)
pointer to only point into >= LOW_PM monste entries.
2024-01-06 12:06:54 -08:00
Mika Kuoppala e6c4838161 sp_lvl: fix memory leak on lspo_region
If tutorial is entered, we get following leak on exit:

=================================================================
==81358==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 96 byte(s) in 3 object(s) allocated from:
    #0 0x7f6996edefdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
        #1 0x5601c255bcbb in alloc /home/miku/src/NetHack/src/alloc.c:71

Indirect leak of 5064 byte(s) in 3 object(s) allocated from:
    #0 0x7f6996edefdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
        #1 0x5601c255be1e in alloc /home/miku/src/NetHack/src/alloc.c:71
	    #2 0x5601c255be1e in dupstr /home/miku/src/NetHack/src/alloc.c:236

SUMMARY: AddressSanitizer: 5160 byte(s) leaked in 6 allocation(s).

Fix this by freeing the cloned selection before returning.
2023-12-17 11:47:26 +02:00