mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
Fix CID 1393540 (Explicit null dereferenced)
Coverity Scan does not like incrementing of a null pointer, so increment an index value instead of a pointer. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
c8dd4456e0
commit
d6391ee811
@ -475,20 +475,22 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) {
|
||||
if (!(flags & FL_SPLAT)) {
|
||||
sarg = va_arg(ap, char *);
|
||||
}
|
||||
char *sp = sarg;
|
||||
unsigned length = 0;
|
||||
while (width--) {
|
||||
q = fgetc(stream);
|
||||
if (isspace(static_cast<unsigned char>(q)) || q <= 0) {
|
||||
ungetc(q, stream);
|
||||
break;
|
||||
}
|
||||
if (!(flags & FL_SPLAT)) *sp = q;
|
||||
sp++;
|
||||
if (!(flags & FL_SPLAT)) {
|
||||
sarg[length] = q;
|
||||
}
|
||||
length++;
|
||||
}
|
||||
if (sarg == sp) {
|
||||
if (length == 0) {
|
||||
bail = BAIL_EOF;
|
||||
} else if (!(flags & FL_SPLAT)) {
|
||||
*sp = '\0'; // Terminate output
|
||||
sarg[length] = '\0'; // Terminate output
|
||||
converted++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user