Skip to content

Commit

Permalink
Check for invalid digits when parsing octal constants
Browse files Browse the repository at this point in the history
Originally, the parser had the ability to parse octal numbers
but did not check whether the digits were valid. Therefore, this
commit improves the implementation to include the validation check.
  • Loading branch information
DrXiao committed Sep 15, 2024
1 parent 2c852d0 commit 3b9da12
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,10 @@ void read_numeric_param(block_t *parent, basic_block_t *bb, int is_neg)
} while (is_hex(token[i]));
} else { /* octal */
do {
c = token[i++] - '0';
c = token[i++];
if (c > '7' || c < '0')
error("Invalid numeric constant");
c -= '0';
value = (value * 8) + c;
} while (is_digit(token[i]));
}
Expand Down

0 comments on commit 3b9da12

Please sign in to comment.