diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-07-27 16:17:44 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-07-27 23:19:14 +0000 |
commit | 5623b7917ecf67ff4c5772e6e33ff3d9ce248284 (patch) | |
tree | 3167a879dc81e410e63601977d083fee4e02e9a6 /tools/pidl/lib | |
parent | 692f0145f45f93b67be2a2ee4067de84f78cc6f7 (diff) |
Copy over change from Samba repository:
commit 90bf114f6370ee837d97e36eb25f38f8234dcd39
Author: Andrew Bartlett <abartlet@samba.org>
Date: Thu Feb 25 13:57:37 2016 +1300
pidl: Use a tmp_ctx helper variable
This is so we free the ndr_push_struct_blob() return value after
we make it into a string
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Shouldn't affect us, but it makes diffing cleaner.
Change-Id: I52ee911f89813e6f5a90445be4eb52494e3f69d3
Reviewed-on: https://code.wireshark.org/review/16739
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'tools/pidl/lib')
-rw-r--r-- | tools/pidl/lib/Parse/Pidl/Samba4/Python.pm | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm b/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm index 5982498525..6778ff891b 100644 --- a/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/tools/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -269,17 +269,28 @@ sub PythonStruct($$$$$$) $self->pidl("{"); $self->indent; $self->pidl("$cname *object = ($cname *)pytalloc_get_ptr(py_obj);"); + $self->pidl("PyObject *ret = NULL;"); $self->pidl("DATA_BLOB blob;"); $self->pidl("enum ndr_err_code err;"); - $self->pidl("err = ndr_push_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_$name);"); + $self->pidl("TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));"); + $self->pidl("if (tmp_ctx == NULL) {"); + $self->indent; + $self->pidl("PyErr_SetNdrError(NDR_ERR_ALLOC);"); + $self->pidl("return NULL;"); + $self->deindent; + $self->pidl("}"); + $self->pidl("err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_$name);"); $self->pidl("if (err != NDR_ERR_SUCCESS) {"); $self->indent; + $self->pidl("TALLOC_FREE(tmp_ctx);"); $self->pidl("PyErr_SetNdrError(err);"); $self->pidl("return NULL;"); $self->deindent; $self->pidl("}"); $self->pidl(""); - $self->pidl("return PyString_FromStringAndSize((char *)blob.data, blob.length);"); + $self->pidl("ret = PyString_FromStringAndSize((char *)blob.data, blob.length);"); + $self->pidl("TALLOC_FREE(tmp_ctx);"); + $self->pidl("return ret;"); $self->deindent; $self->pidl("}"); $self->pidl(""); |