diff options
author | cmumford <cmumford@google.com> | 2017-07-20 15:00:13 -0700 |
---|---|---|
committer | Victor Costan <pwnall@chromium.org> | 2017-08-24 15:40:54 -0700 |
commit | 09a3c8e7417547829b94bcdaa62cdf9e896f29a9 (patch) | |
tree | 133401de77ab5632dca19524a649ebee091ad435 | |
parent | 2964b803b857932ff7499d7bebb61dc5514dab7c (diff) | |
download | leveldb-09a3c8e7417547829b94bcdaa62cdf9e896f29a9.tar.gz |
Switched variable type from int to uint64_t in ConsumeDecimalNumber.
An Android test was occasionally crashing with a SEGV in ConsumeDecimalNumber
Switching a local variable from an int to uint64_t eliminated these crashes.
Speculating this is either a compiler, runtime library, or emulator issue.
Switching this type to uint64_t also eliminates a compiler warning
about comparing an int with a uint64_t.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166399695
-rw-r--r-- | util/logging.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/util/logging.cc b/util/logging.cc index ca6b324..d48b6dd 100644 --- a/util/logging.cc +++ b/util/logging.cc @@ -52,7 +52,8 @@ bool ConsumeDecimalNumber(Slice* in, uint64_t* val) { char c = (*in)[0]; if (c >= '0' && c <= '9') { ++digits; - const int delta = (c - '0'); + // |delta| intentionally unit64_t to avoid Android crash (see log). + const uint64_t delta = (c - '0'); static const uint64_t kMaxUint64 = ~static_cast<uint64_t>(0); if (v > kMaxUint64/10 || (v == kMaxUint64/10 && delta > kMaxUint64%10)) { |