Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a potential use-after-free bug #54

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion comdb2/_ccdb2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,17 @@ cdef class _ParameterValue(object):
(<double*>self.data)[l_index] = obj[l_index]
return
elif all(isinstance(ele, bytes) for ele in obj):
if isinstance(obj, tuple):
owner = obj
else:
# Copy the list into a tuple. If we referenced the list
# directly, another thread could remove an element when
# we drop the GIL, invalidating a pointer we're holding
owner = tuple(obj)

self.type = lib.CDB2_BLOB
self.size = sizeof(blob_descriptor)
self.owner = obj
self.owner = owner
self.data = PyMem_Malloc(self.list_size * self.size)
for l_index in range(self.list_size):
(<blob_descriptor*>self.data)[l_index].size = len(obj[l_index])
Expand Down