Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stweil committed Jun 20, 2018
1 parent c8dd445 commit d6391ee
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/ccutil/scanutils.cpp
Expand Up @@ -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++;
}
}
Expand Down

0 comments on commit d6391ee

Please sign in to comment.