improve null format handling

there was a request to improve the error message, but the whole function
has non-informative errors. (both functions, actually, since the code is
duplicated)
as such, instead of catching it directly, address the assumption that
led to the SIGSEGV and let it be caught by the functions themselves,
thus reusing existing error messages (which can then be improved
separately).
This commit is contained in:
Chloe Kudryavtsev 2023-04-20 11:51:11 -04:00
parent f3192303ab
commit 0902a5a981
1 changed files with 2 additions and 2 deletions

View File

@ -809,9 +809,9 @@ static const char *scanformat(
*(form++) = '%';
const char *p2 = strfrmt;
while (p2 <= p) {
if (strchr(FMT_REPLACE_INTTYPES, *p2) != NULL) {
char *loc = strchr(FMT_REPLACE_INTTYPES, *p2);
if (loc != NULL && *loc != '\0') {
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;