HomeFreeBSD

libcasper: Neuter false positive -Wuse-after-free warnings from GCC 13

Description

libcasper: Neuter false positive -Wuse-after-free warnings from GCC 13

GCC 13 incorrectly thinks a call to free after a failed realloc is a
use after free.

lib/libcasper/services/cap_grp/cap_grp.c: In function 'group_resize':
lib/libcasper/services/cap_grp/cap_grp.c:65:17: error: pointer 'buf' may be used after 'realloc' [-Werror=use-after-free]

65 |                 free(buf);
   |                 ^~~~~~~~~

lib/libcasper/services/cap_grp/cap_grp.c:63:19: note: call to 'realloc' here

63 |         gbuffer = realloc(buf, gbufsize);
   |                   ^~~~~~~~~~~~~~~~~~~~~~

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D42576

(cherry picked from commit b7f7cc25c01aeacaafb86ebcffdeb258b7933b08)

Details

Provenance
jhbAuthored on Nov 15 2023, 2:34 AM
Reviewer
imp
Differential Revision
D42576: libcasper: Neuter false positive -Wuse-after-free warnings from GCC 13
Parents
rG415aab2abb75: Merge commit 3537338d1ab9 from llvm git (by Nikolas Klauser):
Branches
Unknown
Tags
Unknown