Merge pull request #1648 from stweil/fix

scanutils: Fix illegal memory access
This commit is contained in:
zdenop 2018-06-08 19:01:45 +02:00 committed by GitHub
commit 89730e12a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -472,8 +472,10 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) {
case 's': // String
{
char *sp;
sp = sarg = va_arg(ap, char *);
if (!(flags & FL_SPLAT)) {
sarg = va_arg(ap, char *);
}
char *sp = sarg;
while (width--) {
q = fgetc(stream);
if (isspace(static_cast<unsigned char>(q)) || q <= 0) {
@ -488,7 +490,6 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) {
} else if (!(flags & FL_SPLAT)) {
*sp = '\0'; // Terminate output
converted++;
} else {
}
}
break;