aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-04-04 03:14:36 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-04-04 03:14:36 +0000
commit72d4b92eaca9390c6f857103c6c8f7b2ee1b6e29 (patch)
tree319a18bcee1689daad880e62848e306a0051eb34
parent5979f14fd56edec6ba853a20dd44bf8e4739b021 (diff)
parent10b0fd4a65a5cb1688336e6d988d20229102c88f (diff)
downloadplatform_external_protobuf-android10-tests-release.tar.gz
platform_external_protobuf-android10-tests-release.tar.bz2
platform_external_protobuf-android10-tests-release.zip
Change-Id: Icf7f1a3252c55f02d3e313ee704773f1def1257a
-rw-r--r--src/google/protobuf/io/coded_stream.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index c81a33ac6..7b742a18e 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -985,7 +985,11 @@ inline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(
}
// Slow path
last_tag_ = ReadTagFallback(first_byte_or_zero);
- return std::make_pair(last_tag_, static_cast<uint32>(last_tag_ - 1) < cutoff);
+ // If last_tag_ == 0 we want to return { 0, false } so the following overflow is intended.
+ // We use __builtin_add_overflow to appease the sub-overflow UB sanitizer.
+ uint32_t last_tag_minus_one;
+ __builtin_add_overflow(last_tag_, -1, &last_tag_minus_one);
+ return std::make_pair(last_tag_, last_tag_minus_one < cutoff);
}
inline bool CodedInputStream::LastTagWas(uint32 expected) {