mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Create new context in pytalloc to avoid problems with talloc_free() freeing the wrong parent of a pointer.
This commit is contained in:
parent
f2d437d646
commit
3f628f4dc9
@ -24,6 +24,7 @@ void py_talloc_dealloc(PyObject* self)
|
||||
{
|
||||
py_talloc_Object *obj = (py_talloc_Object *)self;
|
||||
talloc_free(obj->talloc_ctx);
|
||||
obj->talloc_ctx = NULL;
|
||||
PyObject_Del(self);
|
||||
}
|
||||
|
||||
@ -31,7 +32,13 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
|
||||
void *ptr)
|
||||
{
|
||||
py_talloc_Object *ret = PyObject_New(py_talloc_Object, py_type);
|
||||
ret->talloc_ctx = talloc_reference(NULL, mem_ctx);
|
||||
ret->talloc_ctx = talloc_new(NULL);
|
||||
if (ret->talloc_ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (talloc_reference(ret->talloc_ctx, mem_ctx) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
ret->ptr = ptr;
|
||||
return (PyObject *)ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user