mirror of
https://github.com/janet-lang/janet
synced 2025-08-30 17:38:04 +00:00
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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user