diff options
author | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2023-11-01 19:37:44 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2023-11-06 13:29:07 -0500 |
commit | 2d84486a08c57d00b647586b7cbe2dcec2728e81 (patch) | |
tree | 206f6e80ff67c208e180b6d28bcb0232c217602d /src | |
parent | c5459df18879dad8f5388480d588edbcbd1b7eb2 (diff) | |
download | musl-2d84486a08c57d00b647586b7cbe2dcec2728e81.zip musl-2d84486a08c57d00b647586b7cbe2dcec2728e81.tar.gz musl-2d84486a08c57d00b647586b7cbe2dcec2728e81.tar.bz2 |
__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.
Diffstat (limited to 'src')
-rw-r--r-- | src/time/__year_to_secs.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/time/__year_to_secs.c b/src/time/__year_to_secs.c index 2824ec6..b42f5a6 100644 --- a/src/time/__year_to_secs.c +++ b/src/time/__year_to_secs.c @@ -10,9 +10,9 @@ long long __year_to_secs(long long year, int *is_leap) return 31536000*(y-70) + 86400*leaps; } - int cycles, centuries, leaps, rem; + int cycles, centuries, leaps, rem, dummy; - if (!is_leap) is_leap = &(int){0}; + if (!is_leap) is_leap = &dummy; cycles = (year-100) / 400; rem = (year-100) % 400; if (rem < 0) { |