mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2026-07-23 16:42:46 +02:00
gstrfuncs: Always treat G_MININT64 in g_ascii_strtoll
If g_ascii_strtoll does not use strtoll_l, the result of g_parse_long_long could be G_MININT64 with gboolean negative set. In such a case, returning `- (gint64) result` would lead to an undefined behavior because -G_MININT64 would lead to an implicit integer overflow. Realistically though, this still leads to G_MININT64. Fixes test failure if compiled with ubsan on a platform without strtoll_l.
This commit is contained in:
+1
-1
@@ -1250,7 +1250,7 @@ g_ascii_strtoll (const gchar *nptr,
|
||||
return G_MAXINT64;
|
||||
}
|
||||
else if (negative)
|
||||
return - (gint64) result;
|
||||
return (result == (guint64) G_MININT64) ? G_MININT64 : -(gint64) result;
|
||||
else
|
||||
return (gint64) result;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user