==10068== Invalid read of size 8
==10068== at 0x40EFB1: varlookup (var.c:84)
==10068== by 0x407B04: whatare_all_vars (hash.c:311)
==10068== by 0x401E60: b_whatis (builtins.c:323)
==10068== by 0x402E32: exec (exec.c:92)
==10068== by 0x40F997: walk (walk.c:39)
The reason is that vp[h].p is freed in delete_var(), but the pointer is kept unchanged.
Later the pointer is found to be non-null and dereferenced causing the crash.
Script:
Valgrind stack:
The reason is that
vp[h].p
is freed indelete_var()
, but the pointer is kept unchanged. Later the pointer is found to be non-null and dereferenced causing the crash.