From 5f4a1d91710efbb12f0935bcab0a302e892f4109 Mon Sep 17 00:00:00 2001 From: "Alex Xu (Hello71)" Date: Wed, 1 Nov 2023 19:37:44 -0400 Subject: [PATCH] libroot/musl: __year_to_secs: fix dangling pointer The lifetime of the compound literal ends after the "if" statement's implicit block. gcc also warns about this. Change-Id: I408d77638ab82c5305bfcd31affb2b14070652f4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/9699 Reviewed-by: Adrien Destugues Tested-by: Commit checker robot --- src/system/libroot/posix/musl/time/__year_to_secs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/system/libroot/posix/musl/time/__year_to_secs.c b/src/system/libroot/posix/musl/time/__year_to_secs.c index 9bbe686a40..8febba6e78 100644 --- a/src/system/libroot/posix/musl/time/__year_to_secs.c +++ b/src/system/libroot/posix/musl/time/__year_to_secs.c @@ -11,12 +11,9 @@ long long __year_to_secs(long long year, int *is_leap) } { - int cycles, centuries, leaps, rem; + int cycles, centuries, leaps, rem, dummy; - if (!is_leap) { - static int isleap = 0; - is_leap = &isleap; - } + if (!is_leap) is_leap = &dummy; cycles = (year-100) / 400; rem = (year-100) % 400; if (rem < 0) {