Index: base/strings/string_number_conversions.cc |
diff --git a/base/strings/string_number_conversions.cc b/base/strings/string_number_conversions.cc |
index 642d24e9ada11ad61444fcadd81a0accddb0df65..998e1fdbc3effec12ae0bd11a0f620628c6727ce 100644 |
--- a/base/strings/string_number_conversions.cc |
+++ b/base/strings/string_number_conversions.cc |
@@ -42,7 +42,12 @@ struct IntToStringT { |
template <typename INT2, typename UINT2> |
struct ToUnsignedT<INT2, UINT2, true> { |
static UINT2 ToUnsigned(INT2 value) { |
- return static_cast<UINT2>(value < 0 ? -value : value); |
+ if (value >= 0) { |
+ return value; |
+ } else { |
+ // Avoid integer overflow when negating INT_MIN. |
+ return static_cast<UINT2>(-(value + 1)) + 1; |
+ } |
} |
}; |