avoid crash in scanf when invalid %m format is encountered
invalid format strings invoke undefined behavior, so this is not a conformance issue, but it's nicer for scanf to report the error safely instead of calling free on a potentially-uninitialized pointer or a pointer to memory belonging to the caller.
This commit is contained in:
parent
35e8621a28
commit
cbb8a69790
1 changed files with 2 additions and 0 deletions
|
|
@ -118,6 +118,8 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p=='m') {
|
if (*p=='m') {
|
||||||
|
wcs = 0;
|
||||||
|
s = 0;
|
||||||
alloc = !!dest;
|
alloc = !!dest;
|
||||||
p++;
|
p++;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue