[glib/wip/pwithnall/freebsd-math] WIP




commit 1e3efbc141735b0657e50e477ab4494c7e25a1fb
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Dec 11 14:59:20 2020 +0000

    WIP
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 glib/gdatetime.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index 56eb8cc58..1d17d862f 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -1181,7 +1181,7 @@ static gboolean
 get_iso8601_seconds (const gchar *text, gsize length, gdouble *value)
 {
   gsize i;
-  gdouble divisor = 1, v = 0;
+  guint64 divisor = 1, v = 0;
 
   if (length < 2)
     return FALSE;
@@ -1208,17 +1208,15 @@ get_iso8601_seconds (const gchar *text, gsize length, gdouble *value)
   for (; i < length; i++)
     {
       const gchar c = text[i];
-      if (c < '0' || c > '9')
+      if (c < '0' || c > '9' ||
+          v > (G_MAXUINT64 - (c - '0')) / 10 ||
+          divisor > G_MAXUINT64 / 10)
         return FALSE;
       v = v * 10 + (c - '0');
       divisor *= 10;
     }
 
-  v = v / divisor;
-  if (!isfinite (v))
-    return FALSE;
-
-  *value = v;
+  *value = (gdouble) v / divisor;
   return TRUE;
 }
 
@@ -1590,7 +1588,7 @@ g_date_time_new (GTimeZone *tz,
       day < 1 || day > days_in_months[GREGORIAN_LEAP (year)][month] ||
       hour < 0 || hour > 23 ||
       minute < 0 || minute > 59 ||
-      !isfinite (seconds) ||
+      isnan (seconds) ||
       seconds < 0.0 || seconds >= 60.0)
     return NULL;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]