From 4a75cb9cd5dfdd347803d03acbc0533c2e7e89cc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 24 Jun 2010 23:17:51 +0200 Subject: [PATCH] pidl/python: Increment reference counter on Py_None to prevent us from accidentally deallocating it. --- pidl/lib/Parse/Pidl/Samba4/Python.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 390ee27510..4fb8f6be2c 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -126,6 +126,7 @@ sub FromUnionToPythonFunction($$$$) $self->ConvertObjectToPython($mem_ctx, {}, $e, "$name->$e->{NAME}", "ret", "return NULL;"); } else { $self->pidl("ret = Py_None;"); + $self->pidl("Py_INCREF(ret);"); } $self->pidl("return ret;"); @@ -1052,6 +1053,7 @@ sub ConvertObjectToPythonLevel($$$$$$) $self->pidl("if ($var_name == NULL) {"); $self->indent; $self->pidl("$py_var = Py_None;"); + $self->pidl("Py_INCREF($py_var);"); $self->deindent; $self->pidl("} else {"); $self->indent; -- 2.34.1