From 744bb91c788cc8a821372c8c57ca067d907aad2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Scylla=29?= <stephane.adjemian@univ-lemans.fr> Date: Fri, 27 Jun 2014 18:48:50 +0200 Subject: [PATCH] Fixed bug (test if the returned index is less than UINT_MAX). --- preprocessor/Statement.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/preprocessor/Statement.cc b/preprocessor/Statement.cc index b72e4e24d8..db02db9392 100644 --- a/preprocessor/Statement.cc +++ b/preprocessor/Statement.cc @@ -137,9 +137,18 @@ OptionsList::writeOutput(ostream &output, const string &option_group) const { // Initialize option_group as an empty struct iff the field does not exist! unsigned idx = option_group.find_last_of("."); - output << "if ~isfield(" << option_group.substr(0,idx) << ",'" << option_group.substr(idx+1) << "')" << endl; - output << " " << option_group << " = struct();" << endl; - output << "end" << endl; + if (idx<UINT_MAX) + { + output << option_group << endl; + output << idx << endl; + output << "if ~isfield(" << option_group.substr(0,idx) << ",'" << option_group.substr(idx+1) << "')" << endl; + output << " " << option_group << " = struct();" << endl; + output << "end" << endl; + } + else + { + output << option_group << " = struct();" << endl; + } for (num_options_t::const_iterator it = num_options.begin(); it != num_options.end(); it++) -- GitLab