summaryrefslogtreecommitdiff
path: root/pidl/lib/Parse/Pidl/Samba4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-20 20:02:21 -0700
committerJelmer Vernooij <jelmer@samba.org>2010-09-20 22:40:46 -0700
commita7393449eba9fc5173934096651b2fa232ae6764 (patch)
tree30526d173ef16a17a6bb6bfd1464939200e015b9 /pidl/lib/Parse/Pidl/Samba4
parent5dd47eeac275d8a9da0a47fda3d71f69ee6c0c4a (diff)
downloadsamba-a7393449eba9fc5173934096651b2fa232ae6764.tar.gz
samba-a7393449eba9fc5173934096651b2fa232ae6764.tar.bz2
samba-a7393449eba9fc5173934096651b2fa232ae6764.zip
pidl: Fix segfault when accessing unicode objects.
Diffstat (limited to 'pidl/lib/Parse/Pidl/Samba4')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm11
1 files changed, 10 insertions, 1 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 4ee4a37f94..2c42b0a874 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -1152,7 +1152,16 @@ sub ConvertObjectToPythonLevel($$$$$$)
if (is_charset_array($e, $l)) {
# FIXME: Use Unix charset setting rather than utf-8
- $self->pidl("$py_var = PyUnicode_Decode_check_null($var_name, strlen($var_name), \"utf-8\", \"ignore\");");
+ $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;
+ $self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");");
+ $self->deindent;
+ $self->pidl("}");
} else {
die("No SIZE_IS for array $var_name") unless (defined($l->{SIZE_IS}));
my $length = $l->{SIZE_IS};