1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-25 16:00:27 +00:00

check for NULL in get_fmt_mapping (fixes #1105)

When there is no format to be found after a %, get_fmt_mapping returns
NULL. It then gets called against strlen, which is a typical SEGV.
Check for NULL aginst mapping, which signals a null format being
specified.
This commit is contained in:
Chloe Kudryavtsev 2023-04-19 12:55:25 -04:00
parent bef5bd72c2
commit f3192303ab

View File

@ -811,6 +811,7 @@ static const char *scanformat(
while (p2 <= p) {
if (strchr(FMT_REPLACE_INTTYPES, *p2) != NULL) {
const char *mapping = get_fmt_mapping(*p2++);
if (!mapping) janet_panic("invalid format (found null)");
size_t len = strlen(mapping);
strcpy(form, mapping);
form += len;