mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
gdatetime: Fix a potential overflow in overflow calculations
I can’t remember whether glong (tv.tv_sec) needs to be explicitly promoted to gint64 here, or whether C does it automatically. Safer to make the cast explicit to avoid overflow issues on 32-bit platforms, where glong is 32-bit. Signed-off-by: Philip Withnall <withnall@endlessm.com> https://bugzilla.gnome.org/show_bug.cgi?id=783841
This commit is contained in:
parent
18f8b77c04
commit
2db7aa4799
@ -128,7 +128,7 @@ struct _GDateTime
|
||||
#define INSTANT_TO_UNIX(instant) \
|
||||
((instant)/USEC_PER_SECOND - UNIX_EPOCH_START * SEC_PER_DAY)
|
||||
#define UNIX_TO_INSTANT(unix) \
|
||||
(((unix) + UNIX_EPOCH_START * SEC_PER_DAY) * USEC_PER_SECOND)
|
||||
(((gint64) (unix) + UNIX_EPOCH_START * SEC_PER_DAY) * USEC_PER_SECOND)
|
||||
#define UNIX_TO_INSTANT_IS_VALID(unix) \
|
||||
((gint64) (unix) <= INSTANT_TO_UNIX (G_MAXINT64))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user