From 781cc3d50f18e69bad5faf67ee46f7b1fd28cf2a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 11 Jun 2015 08:54:11 +0200 Subject: pidl:Python: protect for loops against $length being an expression instead of a scalar variable This changes for (value_cntr_1 = 0; value_cntr_1 < r->out.length?*r->out.length:0; value_cntr_1++) { into: for (value_cntr_1 = 0; value_cntr_1 < (r->out.length?*r->out.length:0); value_cntr_1++) { it fixes a possible endless loop resulting in a crash. Signed-off-by: Stefan Metzmacher Reviewed-by: Michael Adam --- pidl/lib/Parse/Pidl/Samba4/Python.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pidl') diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 1d271bfa525..b0a7099f1cf 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -1349,7 +1349,7 @@ sub ConvertObjectToPythonLevel($$$$$$) $self->indent; my $counter = "$e->{NAME}_cntr_$l->{LEVEL_INDEX}"; $self->pidl("int $counter;"); - $self->pidl("for ($counter = 0; $counter < $length; $counter++) {"); + $self->pidl("for ($counter = 0; $counter < ($length); $counter++) {"); $self->indent; my $member_var = "py_$e->{NAME}_$l->{LEVEL_INDEX}"; $self->pidl("PyObject *$member_var;"); -- cgit v1.2.1