pidl:Samba4/Python: PyArg_ParseTuple with "s#" returns 'int' instead of 'size_t'
authorStefan Metzmacher <metze@samba.org>
Mon, 8 Aug 2011 12:00:31 +0000 (14:00 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 8 Aug 2011 14:45:27 +0000 (16:45 +0200)
If we pass variable references we don't get implicit casting!

metze

pidl/lib/Parse/Pidl/Samba4/Python.pm

index db2d79d2f64362e1db2837da639131db44ae0d3a..1622e71efbc44b3187eb865a63d0b8d07c96250d 100644 (file)
@@ -276,9 +276,14 @@ sub PythonStruct($$$$$$)
                $self->indent;
                $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
                $self->pidl("DATA_BLOB blob;");
+               $self->pidl("int blob_length = 0;");
                $self->pidl("enum ndr_err_code err;");
-               $self->pidl("if (!PyArg_ParseTuple(args, \"s#:__ndr_unpack__\", &blob.data, &blob.length))");
-               $self->pidl("\treturn NULL;");
+               $self->pidl("if (!PyArg_ParseTuple(args, \"s#:__ndr_unpack__\", &blob.data, &blob_length)) {");
+               $self->indent;
+               $self->pidl("return NULL;");
+               $self->deindent;
+               $self->pidl("}");
+               $self->pidl("blob.length = blob_length;");
                $self->pidl("");
                $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
                $self->pidl("if (err != NDR_ERR_SUCCESS) {");