summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-02-10 03:19:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:37 -0500
commit57f69e6f37949636ae14c646517792fa40c9c75b (patch)
tree39bb13efba835528dd43e3aa17119ad74b5c0256
parent22adab2004d56918b40fff0f0716d8a889c9f007 (diff)
downloadsamba-57f69e6f37949636ae14c646517792fa40c9c75b.tar.gz
samba-57f69e6f37949636ae14c646517792fa40c9c75b.tar.bz2
samba-57f69e6f37949636ae14c646517792fa40c9c75b.zip
r5293: Map an empty policy handle to None when creating policy handles, and
refuse to accept None as a policy handle when accepting them. Now we don't segfault after running the samr_Shutdown() test. (This used to be commit 2f0419c4d8100864ddddf5629d1808b655da9d76)
-rw-r--r--source4/scripting/swig/dcerpc.i23
1 files changed, 20 insertions, 3 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i
index 471140c499..3d9d076e58 100644
--- a/source4/scripting/swig/dcerpc.i
+++ b/source4/scripting/swig/dcerpc.i
@@ -182,14 +182,31 @@ const char *dcerpc_server_name(struct dcerpc_pipe *p);
$result = PyLong_FromLong(*$1);
}
+%typemap(in) struct policy_handle * {
+
+ if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,
+ SWIG_POINTER_EXCEPTION)) == -1)
+ return NULL;
+
+ if ($1 == NULL) {
+ PyErr_SetString(PyExc_TypeError, "None is not a valid policy handle");
+ return NULL;
+ }
+}
+
/* When returning a policy handle to Python we need to make a copy of
as the talloc context it is created under is destroyed after the
wrapper function returns. TODO: Fix memory leak created here. */
%typemap(out) struct policy_handle * {
- struct policy_handle *temp = (struct policy_handle *)malloc(sizeof(struct policy_handle));
- memcpy(temp, $1, sizeof(struct policy_handle));
- $result = SWIG_NewPointerObj(temp, SWIGTYPE_p_policy_handle, 0);
+ if ($1) {
+ struct policy_handle *temp = (struct policy_handle *)malloc(sizeof(struct policy_handle));
+ memcpy(temp, $1, sizeof(struct policy_handle));
+ $result = SWIG_NewPointerObj(temp, SWIGTYPE_p_policy_handle, 0);
+ } else {
+ Py_INCREF(Py_None);
+ $result = Py_None;
+ }
}
%{