Browse Source

__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.
Alex Xu (Hello71) 1 year ago
parent
commit
2d84486a08
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/time/__year_to_secs.c

+ 2 - 2
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) {