digikar99 / unboxables

A simple wrapper around CFFI to enable contiguously allocated arrays of structures in Common Lisp.
18 stars 0 forks source link

Remove the unnecessary and dangerous `mem-set` in finalizer #2

Closed bohonghuang closed 1 year ago

bohonghuang commented 1 year ago

The (setf (mem-ref ...) ...) here is unnecessary and writing data to a memory that has already been released will cause a segmentation fault, leading to a crash of the Lisp session:

https://github.com/digikar99/unboxables/blob/7f877eb39caa6d018e86a2c62d1afd68d2a215c7/unboxables.lisp#L50-L53

digikar99 commented 1 year ago

Right, in C, we might set the pointer to NULL, not the data at the pointer! Thanks for the fix!