Skip to content

Commit 4b90420

Browse files
committed
Check for invalid digits when parsing octal constants
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.
1 parent 2c852d0 commit 4b90420

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/parser.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,10 @@ void read_numeric_param(block_t *parent, basic_block_t *bb, int is_neg)
634634
} while (is_hex(token[i]));
635635
} else { /* octal */
636636
do {
637-
c = token[i++] - '0';
637+
c = token[i++];
638+
if (c > '7')
639+
error("Invalid numeric constant");
640+
c -= '0';
638641
value = (value * 8) + c;
639642
} while (is_digit(token[i]));
640643
}

0 commit comments

Comments
 (0)