On Thu, Dec 5, 2024 at 1:55 AM Heiko Eißfeldt <he...@hexco.de> wrote: > > As commented in PR114541 here is a first patch that > 1. replaces atoi() with strtoul() with ERANGE checking and > 2. fixes the handling of misparsed gimple compounds to return early. > 3. adds two new test cases. > > There is more work to do for Andrews testcase to succeed, so PR114541 > is not done yet. > > === > > Replace atoi() with strtoul() with ERANGE checking. > > The function c_parser_gimple_parse_bb_spec uses atoi, > which can silently return valid numbers even for > some too large numbers in the string. > > Furthermore in function c_parser_parse_gimple_body > handle the case of gimple compound statement errors > more generically. In the case of cdil != cdil_gimple > now consider them as errors and return early. > This avoids further processing with erroneous data.
c_parser_gimple_compound_statement returns whether the compound statement ended with a return statement, not whether there was an error, so this change looks wrong. The hunk in c_parser_gimple_parse_bb_spec is OK. Richard. > 2024-12-05 Heiko Eißfeldt <he...@hexco.de> > > PR c/114541 > * gimple-parser.cc (c_parser_gimple_parse_bb_spec): > Use strtoul with ERANGE check instead of atoi > > * gimple-parser.cc (c_parser_parse_gimple_body): > separate check for errors in c_parser_gimple_compound_statement > and special handling of cdil == cdil_gimple to allow > a return in case of errors for cdil != cdil_gimple > > * gcc.dg/pr114541-else-BB#-and-garbagechar.c: New test. > * gcc.dg/pr114541-then-BB#-and-garbagechar.c: New test. > > > Signed-off-by: Heiko Eißfeldt <he...@hexco.de> > > > >