summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-05-23 15:09:51 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-05-23 15:09:51 +0200
commitdff31b1dc0ec1aea8cec9d5764f4f3a4c109a848 (patch)
tree19263a12f2facbd6ebd2862cebb41edb08ecad57 /source4
parent9adcd8c25e7e51ac7e4767763750c67e334bcdbb (diff)
downloadsamba-dff31b1dc0ec1aea8cec9d5764f4f3a4c109a848.tar.gz
samba-dff31b1dc0ec1aea8cec9d5764f4f3a4c109a848.tar.bz2
samba-dff31b1dc0ec1aea8cec9d5764f4f3a4c109a848.zip
Create new context in pytalloc to avoid problems with talloc_free() freeing the wrong parent of a pointer.
(This used to be commit 3f628f4dc9a57326442ebe2d2eaac9d279043aa6)
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/pytalloc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c
index d669eb0f24..ca476e9604 100644
--- a/source4/scripting/python/pytalloc.c
+++ b/source4/scripting/python/pytalloc.c
@@ -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;
}