mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
pidl: Fix subscripts of dereferenced arrays
Pidl will generate code like the following: py_out_2 = PyLong_FromLong((uint16_t)*r->out.out[out_cntr_2]); As the array subscripting operator has a higher precedence than the indirection (derference) operator, the argument will be evaluated as (uint16_t)*(r->out.out[out_cntr_2]), which is wrong. Fix Pidl to generate the following code instead: py_out_2 = PyLong_FromLong((uint16_t)(*r->out.out)[out_cntr_2]); Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
dbc9c9bd12
commit
3da132a8df
@ -2015,9 +2015,9 @@ sub ConvertObjectFromPythonLevel($$$$$$$$$)
|
||||
$self->pidl("for ($counter = 0; $counter < PyList_GET_SIZE($py_var); $counter++) {");
|
||||
$self->indent;
|
||||
if (ArrayDynamicallyAllocated($e, $l)) {
|
||||
$self->ConvertObjectFromPythonLevel($env, $var_name, "PyList_GET_ITEM($py_var, $counter)", $e, $nl, $var_name."[$counter]", $fail, 0);
|
||||
$self->ConvertObjectFromPythonLevel($env, $var_name, "PyList_GET_ITEM($py_var, $counter)", $e, $nl, "($var_name)"."[$counter]", $fail, 0);
|
||||
} else {
|
||||
$self->ConvertObjectFromPythonLevel($env, $mem_ctx, "PyList_GET_ITEM($py_var, $counter)", $e, $nl, $var_name."[$counter]", $fail, 0);
|
||||
$self->ConvertObjectFromPythonLevel($env, $mem_ctx, "PyList_GET_ITEM($py_var, $counter)", $e, $nl, "($var_name)"."[$counter]", $fail, 0);
|
||||
}
|
||||
$self->deindent;
|
||||
$self->pidl("}");
|
||||
@ -2272,9 +2272,9 @@ sub ConvertObjectToPythonLevel($$$$$$$)
|
||||
my $member_var = "py_$e->{NAME}_$l->{LEVEL_INDEX}";
|
||||
$self->pidl("PyObject *$member_var;");
|
||||
if (ArrayDynamicallyAllocated($e, $l)) {
|
||||
$self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, $var_name."[$counter]", $member_var, $fail, $recurse);
|
||||
$self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, "($var_name)"."[$counter]", $member_var, $fail, $recurse);
|
||||
} else {
|
||||
$self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, $nl, $var_name."[$counter]", $member_var, $fail, $recurse);
|
||||
$self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, $nl, "($var_name)"."[$counter]", $member_var, $fail, $recurse);
|
||||
}
|
||||
$self->pidl("PyList_SetItem($py_var, $counter, $member_var);");
|
||||
$self->deindent;
|
||||
|
Loading…
Reference in New Issue
Block a user