[gjs/gnome-3-24] arg: Avoid taking abs() of -2^63



commit 27a143c89dedc44921c046302906681a94654956
Author: Philip Chimento <philip endlessm com>
Date:   Wed Aug 30 13:36:51 2017 -0700

    arg: Avoid taking abs() of -2^63
    
    It's undefined behaviour to call abs() on (int64_t)(-2^63) because 2^63
    can't be stored in an int64_t. Add a special case for this value.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786995

 gi/arg.cpp |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 4b42550..bcc43e2 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2617,7 +2617,8 @@ gjs_value_from_g_argument (JSContext             *context,
         break;
 
     case GI_TYPE_TAG_INT64:
-        if (std::abs(arg->v_int64) > MAX_SAFE_INT64)
+        if (arg->v_int64 == G_MININT64 ||
+            std::abs(arg->v_int64) > MAX_SAFE_INT64)
             g_warning("Value %" G_GINT64_FORMAT " cannot be safely stored in "
                       "a JS Number and may be rounded", arg->v_int64);
         value_p.setNumber(static_cast<double>(arg->v_int64));


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