gastamper / groundzero2

A fork of the GroundZero2 codebase with bug fixes, standardization, and sanity-related changes.
8 stars 7 forks source link

Purging clones of vehicles causes a segmentation fault. #2

Closed gastamper closed 7 years ago

gastamper commented 7 years ago

x_extract_obj() is called on containers (such as vehicles) when purged to empty their contents before removing them. In the case of vehicles, clones will have an incorrect sizeof(struct obj_vehicle_data) passed to the free_mem() portion of handler.c responsible for performing the purge; the incorrect sMem parameter for free_mem() thus causes a segmentation fault.

gastamper commented 7 years ago

This was resolved by changing clones of vehicles to use alloc_mem() instead of alloc_perm().

gastamper commented 7 years ago

The original implementation using alloc_perm() was also a massive waste of memory as it allocated MAX_PERM_BLOCK (262144) instead of sizeof(struct obj_vehicledata which is normally ~88 bytes or so.