[gjs] arg: Avoid taking abs() of -2^63
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] arg: Avoid taking abs() of -2^63
- Date: Fri, 1 Sep 2017 00:10:33 +0000 (UTC)
commit 9a3e33990996d2a276f6a3930983ba6a44cdd62d
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 d0647fe..34be3a4 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -2623,7 +2623,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]