| Index: base/debug/stack_trace_posix.cc
|
| diff --git a/base/debug/stack_trace_posix.cc b/base/debug/stack_trace_posix.cc
|
| index 2eac14e35380d12dd426add3001de08d910ecc08..9593962d3aa838019b839c3df8a36ff9facd2a83 100644
|
| --- a/base/debug/stack_trace_posix.cc
|
| +++ b/base/debug/stack_trace_posix.cc
|
| @@ -784,7 +784,8 @@ char *itoa_r(intptr_t i, char *buf, size_t sz, int base, size_t padding) {
|
|
|
| // Handle negative numbers (only for base 10).
|
| if (i < 0 && base == 10) {
|
| - j = -i;
|
| + // This does "j = -i" while avoiding integer overflow.
|
| + j = static_cast<uintptr_t>(-(i + 1)) + 1;
|
|
|
| // Make sure we can write the '-' character.
|
| if (++n > sz) {
|
|
|