summaryrefslogtreecommitdiff
path: root/pidl
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-08-22 14:47:22 +1000
committerAndrew Tridgell <tridge@samba.org>2010-08-22 14:57:34 +1000
commit34b86155743f0ef1916bc3ae15907961c230c9ab (patch)
tree2479ab0c282b43e5013fe0e1ff984c2eabbc071d /pidl
parent5a025c82f566b378a125abf0f9e74fc076d394c0 (diff)
downloadsamba-34b86155743f0ef1916bc3ae15907961c230c9ab.tar.gz
samba-34b86155743f0ef1916bc3ae15907961c230c9ab.tar.bz2
samba-34b86155743f0ef1916bc3ae15907961c230c9ab.zip
pidl: cope with bad type conversions in unions
This prevents a crash when converting bad types in NDR unions Pair-Programmed-With: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'pidl')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index b7d70fafaf..f7968b4e0a 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -986,7 +986,15 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
} elsif ($l->{TYPE} eq "SWITCH") {
$var_name = get_pointer_to($var_name);
my $switch = ParseExpr($l->{SWITCH_IS}, $env, $e);
- $self->assign($var_name, "py_export_" . GetNextLevel($e, $l)->{DATA_TYPE} . "($mem_ctx, $switch, $py_var)");
+ my $switch_ptr = "$e->{NAME}_switch_$l->{LEVEL_INDEX}";
+ $self->pidl("{");
+ $self->indent;
+ $self->pidl("void *$switch_ptr;");
+ $self->pidl("$switch_ptr = py_export_" . GetNextLevel($e, $l)->{DATA_TYPE} . "($mem_ctx, $switch, $py_var);");
+ $self->pidl("if ($switch_ptr == NULL) { $fail }");
+ $self->assign($var_name, "$switch_ptr");
+ $self->deindent;
+ $self->pidl("}");
} elsif ($l->{TYPE} eq "SUBCONTEXT") {
$self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, GetNextLevel($e, $l), $var_name, $fail);
} else {