pytalloc: use talloc_unlink() to free py_talloc objects
authorKamen Mazdrashki <kamenim@samba.org>
Fri, 8 Oct 2010 01:21:07 +0000 (04:21 +0300)
committerKamen Mazdrashki <kamenim@samba.org>
Wed, 20 Oct 2010 21:37:06 +0000 (21:37 +0000)
Those type of objects are referenced every time we assign
them to other py_talloc objects, which leads to runtime
warnings that we are trying to free an object with references

Wrap talloc_unlink() in SMB_ASSERT() to ensure we catch possible failure

Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Wed Oct 20 21:37:06 UTC 2010 on sn-devel-104

lib/talloc/pytalloc.c

index b0b7394875f056283f9ff0e5be9a203c824da790..ae59b6962594088b4e5ccf3dd6b471bd4c1e7135 100644 (file)
@@ -21,6 +21,8 @@
 #include "replace.h"
 #include <talloc.h>
 #include "pytalloc.h"
+#include "lib/util/debug.h"
+#include "lib/util/util.h"
 
 /**
  * Simple dealloc for talloc-wrapping PyObjects
@@ -28,7 +30,7 @@
 void py_talloc_dealloc(PyObject* self)
 {
        py_talloc_Object *obj = (py_talloc_Object *)self;
-       talloc_free(obj->talloc_ctx);
+       SMB_ASSERT(talloc_unlink(NULL, obj->talloc_ctx) != -1);
        obj->talloc_ctx = NULL;
        self->ob_type->tp_free(self);
 }