From e7e39584a9dcfd7d98dc10b88baa53019a77e652 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 28 Aug 2010 21:53:27 +1000 Subject: pytalloc: treat a NULL ptr as Py_None --- lib/talloc/pytalloc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c index 92b7b94052..ccf27f5fa0 100644 --- a/lib/talloc/pytalloc.c +++ b/lib/talloc/pytalloc.c @@ -68,7 +68,13 @@ PyObject *py_talloc_steal(PyTypeObject *py_type, void *ptr) */ PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, void *ptr) { - py_talloc_Object *ret = (py_talloc_Object *)py_type->tp_alloc(py_type, 0); + py_talloc_Object *ret; + + if (ptr == NULL) { + Py_RETURN_NONE; + } + + ret = (py_talloc_Object *)py_type->tp_alloc(py_type, 0); ret->talloc_ctx = talloc_new(NULL); if (ret->talloc_ctx == NULL) { return NULL; -- cgit