Fix Unpacker __init__ re-entry cleanup leaks

This commit is contained in:
copilot-swe-agent[bot] 2026-06-03 07:20:54 +00:00 committed by GitHub
parent 6afc0cc2ed
commit ffc1b206db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 0 deletions

View file

@ -319,6 +319,7 @@ cdef class Unpacker:
def __cinit__(self):
self.buf = NULL
unpack_init(&self.ctx)
def __dealloc__(self):
unpack_clear(&self.ctx)
@ -338,6 +339,12 @@ cdef class Unpacker:
Py_ssize_t max_ext_len=-1):
cdef const char *cerr=NULL
unpack_clear(&self.ctx)
unpack_init(&self.ctx)
if self.buf != NULL:
PyMem_Free(self.buf)
self.buf = NULL
self.object_hook = object_hook
self.object_pairs_hook = object_pairs_hook
self.list_hook = list_hook