mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-25 11:42:10 +01:00
gdatetime: Widen a variable before multiplication
Otherwise it could possibly overflow on 32-bit machines if `year` is high enough, although I don’t think that’s possible because of limits applied on it by callers. This should shut Coverity up though. The limits applied by callers could be circumvented by calling (say) `g_date_time_add_years()` multiple times. That’s a bug, but not one I’m going to fix today. Coverity CID: #1159479 Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
c50fb4f317
commit
b0be67cc3f
@ -598,7 +598,7 @@ ymd_to_days (gint year,
|
||||
{
|
||||
gint64 days;
|
||||
|
||||
days = (year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100)
|
||||
days = ((gint64) year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100)
|
||||
+ ((year - 1) / 400);
|
||||
|
||||
days += days_in_year[0][month - 1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user