RPGHacker / asar

(Now) official repository of the SNES assembler Asar, originally created by Alcaro
Other
199 stars 42 forks source link

Segfault on asar_patch when using as a static library #270

Closed VirusRushTheater closed 1 year ago

VirusRushTheater commented 1 year ago

I've tracked the error and it's because the variable romdata_r at interface_lib.cpp gets freed twice: First on asar_patch_begin->resetdllstuff->reseteverything and then on asar_patch_end because it triggers the condition where that variable is freed (again). This is where the program I'm using Asar on triggers a segmentation fault.

I suggest the usage of an additional flag to check whether to free romdata_r, or making it NULL and check again.

EDIT: I commented the block where it frees the variable in reseteverything and it worked properly, even though I've silenced the Sanitizer.

VirusRushTheater commented 1 year ago

Update: I have replaced on main.cpp:982 #ifndef ASAR_SHARED Which would be meant to CLI builds of asar (which won't include static library builds) with: #if (!defined(ASAR_SHARED) && !defined(ASAR_STATIC))