Skip to content

Commit

Permalink
Check return value from sscanf(), found by Coverity Scan
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Dec 17, 2023
1 parent 8e296da commit 499ece9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/meminfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ static void cb(uev_t *w, void *arg, int events)

if (!strncmp(buf, meminfo[i].str, len)) {
char *ptr = buf + len + 1;
uint32_t val;

while (isspace(*ptr))
ptr++;

sscanf(ptr, "%u kB", &meminfo[i].val);
if (sscanf(ptr, "%u kB", &val) == 1)
meminfo[i].val = val;
}
}
}
Expand Down

0 comments on commit 499ece9

Please sign in to comment.