[glibmm] gmmproc: Better error checks in some _WRAP_* macros
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] gmmproc: Better error checks in some _WRAP_* macros
- Date: Mon, 1 Sep 2014 14:58:42 +0000 (UTC)
commit b671bb745680c8b98854dc748ae80849ccff06d5
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Mon Sep 1 16:54:53 2014 +0200
gmmproc: Better error checks in some _WRAP_* macros
* tools/pm/Output.pm: When reordering parameters (cpp_type cpp_name{c_name}),
check that there really are C parameters with the given names.
A missing check together with a mis-spelt C parameter name can cause an
infinite loop in _WRAP_SIGNAL and _WRAP_VFUNC.
tools/pm/Output.pm | 46 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 42 insertions(+), 4 deletions(-)
---
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index 1a00d66..d1d3b1e 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -1051,7 +1051,7 @@ sub convert_args_cpp_to_c($$$$$)
# is an output parameter since it will be readded.
my $cpp_index = $num_cpp_args - 1;
$cpp_index++ if($has_output_param);
- $$c_param_name_mappings{ $c_param_names[$num_c_args_expected]} = $cpp_index;
+ $$c_param_name_mappings{$$c_param_names[$num_c_args_expected]} = $cpp_index;
}
# If the method has a slot temporarily decrement the C arg count when
@@ -1077,6 +1077,22 @@ sub convert_args_cpp_to_c($$$$$)
# the number of C++ arguments.
$num_cpp_args++ if($has_output_param);
+ if ($index == 0)
+ {
+ # Check if the C param names in %$c_param_name_mappings exist.
+ foreach my $mapped_c_param_name (keys %$c_param_name_mappings)
+ {
+ next if $mapped_c_param_name eq "" || $mapped_c_param_name eq "OUT";
+
+ if (!grep($_ eq $mapped_c_param_name, @$c_param_names))
+ {
+ Output::error("convert_args_cpp_to_c(): There is no C argument called \"$mapped_c_param_name\"\n");
+ $objCDefsFunc->dump();
+ return ("", "", "");
+ }
+ }
+ }
+
# Get the desired argument list combination.
my $possible_arg_list = $$objCppfunc{possible_args_list}[$index];
@@ -1101,7 +1117,7 @@ sub convert_args_cpp_to_c($$$$$)
# Account for a possible C++ output param in the C++ arg list.
$iCParam-- if($has_output_param && $i > $output_param_index);
- my $c_param_name = @$c_param_names[$iCParam];
+ my $c_param_name = $$c_param_names[$iCParam];
my $cpp_param_index = $i;
$cpp_param_index = $$c_param_name_mappings{$c_param_name}
if(defined($$c_param_name_mappings{$c_param_name}));
@@ -1285,6 +1301,7 @@ sub convert_args_c_to_cpp($$$)
# Loop through the C++ parameters:
my $i;
my $cpp_param_max = $num_cpp_args;
+ my $num_c_args = scalar(@{$c_param_names});
for ($i = 0; $i < $cpp_param_max; $i++)
{
@@ -1298,7 +1315,13 @@ sub convert_args_c_to_cpp($$$)
$cParamName = $cpp_index_param_mappings{$i};
# Get the C index based on the C param name.
- ++$c_index until $$c_param_names[$c_index] eq $cParamName;
+ ++$c_index until $c_index >= $num_c_args || $$c_param_names[$c_index] eq $cParamName;
+ if ($c_index >= $num_c_args)
+ {
+ Output::error("convert_args_c_to_cpp(): There is no C argument called \"$cParamName\"\n");
+ $objCDefsFunc->dump();
+ return "";
+ }
}
else
{
@@ -1407,6 +1430,21 @@ sub get_ctor_properties($$$$$$)
return "";
}
+ if ($index == 0)
+ {
+ # Check if the C param names in %$c_param_name_mappings exist.
+ foreach my $mapped_c_param_name (keys %$c_param_name_mappings)
+ {
+ next if $mapped_c_param_name eq "";
+
+ if (!grep($_ eq $mapped_c_param_name, @$c_param_names))
+ {
+ Output::error("get_ctor_properties(): There is no C argument called \"$mapped_c_param_name\"\n");
+ $objCDefsFunc->dump();
+ return ("", "", "");
+ }
+ }
+ }
# Get the desired argument list combination.
my $possible_arg_list = $$objCppfunc{possible_args_list}[$index];
@@ -1416,7 +1454,7 @@ sub get_ctor_properties($$$$$$)
for ($i = 0; $i < $num_args; $i++)
{
- my $c_param_name = @$c_param_names[$i];
+ my $c_param_name = $$c_param_names[$i];
my $cpp_param_index = $i;
$cpp_param_index = $$c_param_name_mappings{$c_param_name}
if(defined($$c_param_name_mappings{$c_param_name}));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]