From f3192303ab562b3b21a73faa1267bf85173d0e5a Mon Sep 17 00:00:00 2001 From: Chloe Kudryavtsev Date: Wed, 19 Apr 2023 12:55:25 -0400 Subject: [PATCH] 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. --- src/core/pp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/pp.c b/src/core/pp.c index cd545ad1..d55b8536 100644 --- a/src/core/pp.c +++ b/src/core/pp.c @@ -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;