aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2025-04-25 15:27:08 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2025-04-25 17:46:06 -0300
commit7ebb8ec3c78d8fe5428b41ce37cae7a60e865b66 (patch)
treea974bd1a3a02a34d203c04cd29561c52480315b9
parent46b2287d66be14eb72317035b81f3cb2564cb991 (diff)
downloadglibc-azanella/ubsan-undef.tar.xz
glibc-azanella/ubsan-undef.zip
gmon: Fix UB in sprofilazanella/ubsan-undef
UBSAN: Undefined behaviour in ../sysdeps/posix/sprofil.c:272:16 variable length array bound evaluates to non-positive value 0 Move the VLA to after the porfile stop condition (where size might be zero).
-rw-r--r--sysdeps/posix/sprofil.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sysdeps/posix/sprofil.c b/sysdeps/posix/sprofil.c
index 0af671d001..0a3d1a8e50 100644
--- a/sysdeps/posix/sprofil.c
+++ b/sysdeps/posix/sprofil.c
@@ -269,7 +269,6 @@ int
__sprofil (struct prof *profp, int profcnt, struct timeval *tvp,
unsigned int flags)
{
- struct prof *p[profcnt];
struct itimerval timer;
struct sigaction act;
int i;
@@ -295,6 +294,7 @@ __sprofil (struct prof *profp, int profcnt, struct timeval *tvp,
return 0;
}
+ struct prof *p[profcnt];
prof_info.num_regions = 0;
prof_info.region = NULL;
prof_info.overflow = &default_overflow_region;