mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 00:10: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:
parent
bef5bd72c2
commit
f3192303ab
@ -811,6 +811,7 @@ static const char *scanformat(
|
|||||||
while (p2 <= p) {
|
while (p2 <= p) {
|
||||||
if (strchr(FMT_REPLACE_INTTYPES, *p2) != NULL) {
|
if (strchr(FMT_REPLACE_INTTYPES, *p2) != NULL) {
|
||||||
const char *mapping = get_fmt_mapping(*p2++);
|
const char *mapping = get_fmt_mapping(*p2++);
|
||||||
|
if (!mapping) janet_panic("invalid format (found null)");
|
||||||
size_t len = strlen(mapping);
|
size_t len = strlen(mapping);
|
||||||
strcpy(form, mapping);
|
strcpy(form, mapping);
|
||||||
form += len;
|
form += len;
|
||||||
|
Loading…
Reference in New Issue
Block a user