Skip to content

Commit

Permalink
Nuke gcc-13 false positive warning
Browse files Browse the repository at this point in the history
  • Loading branch information
bbonev committed Feb 26, 2024
1 parent d88785e commit d880417
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vmstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ inline int get_vm_counters(uint64_t *pgpgin,uint64_t *pgpgou) {

for (;;) {
ssize_t l=read(fd,buf+bp,bs-bp);

if (l<=0)
break;
if (l==bs-bp) {
t=realloc(buf,bs+BSIZ);

if (!t) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
free(buf); // gcc-13 yields false positive -Wuse-after-free here
#pragma GCC diagnostic pop
close(fd);
return ENOMEM;
}
Expand Down

0 comments on commit d880417

Please sign in to comment.