mirror of
https://github.com/janet-lang/janet
synced 2025-04-11 01:36:38 +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:
parent
f3192303ab
commit
0902a5a981
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user