Source.Python icon indicating copy to clipboard operation
Source.Python copied to clipboard

Pointer.set_pointer(None) causes Segmentation fault.

Open CookStar opened this issue 2 years ago • 1 comments

Isn't this supposed to be set to 0 (NULL)?

Code:

from memory import alloc

pointer = alloc(4, False)
pointer.set_pointer(None)

Output:

Thread 1 "srcds_linux" received signal SIGSEGV, Segmentation fault.
0xf0441c67 in CPointer::SetPtr(boost::python::api::object, int) ()
   from /home/steam/csgo_ds/csgo/addons/source-python/bin/core.so
=> 0xf0441c67 <_ZN8CPointer6SetPtrEN5boost6python3api6objectEi+71>:     8b 48 04        mov    ecx,DWORD PTR [eax+0x4]

CookStar avatar Jun 28 '23 21:06 CookStar

My first guess would be that pPtr is NULL there:

https://github.com/Source-Python-Dev-Team/Source.Python/blob/12a24f43db1e9ae86b233d244d12a6bba12cb351/src/core/modules/memory/memory_utilities.h#L81-L84

jordanbriere avatar Jun 28 '23 22:06 jordanbriere

Definitely a bug, but Jordan is right regarding the design. It's probably better to explicitly use NULL if you want to use a NULL pointer. Though, it's also quite convenient to use None.

Ayuto avatar Apr 18 '25 23:04 Ayuto