Automated rollback of changelist 227019741. See https://crbug.com/921074
*** Reason for rollback ***
It appears that the caller does not expect the method to return an error, which results in weird behavior on 32-bit platforms
*** Original change description ***
Avoid truncation error on 32 bit platforms.
This is so that truncation warning can be turned into compiler errors for Blink
on 32-bit Android platforms. See https://crbug.com/916990 for more context.
gfe-relnote: No functional change on 64-bit platforms. Not flag protected.
***
PiperOrigin-RevId: 229219479
Change-Id: Ie3ef2d518951894f4a1ee8a7b92478f3a946dfa9
diff --git a/http2/hpack/decoder/hpack_string_decoder.h b/http2/hpack/decoder/hpack_string_decoder.h
index 5e0d220..8ec0169 100644
--- a/http2/hpack/decoder/hpack_string_decoder.h
+++ b/http2/hpack/decoder/hpack_string_decoder.h
@@ -13,7 +13,6 @@
#include <algorithm>
#include <cstdint>
-#include <limits>
#include "base/logging.h"
#include "base/macros.h"
@@ -169,16 +168,7 @@
// false otherwise, in which case status set.
template <class Listener>
void OnStringStart(Listener* cb, DecodeStatus* status) {
- // HpackVarintDecoder::value() returns uint64_t.
- const uint64_t value = length_decoder_.value();
- // |remaining_| is size_t. Check for truncation on 32-bit platforms.
- // numeric_limits::max() is constexpr. On platforms where size_t is at
- // least 64 bit wide, the compiler should optimize away this branch.
- if (value > std::numeric_limits<size_t>::max()) {
- *status = DecodeStatus::kDecodeError;
- return;
- }
- remaining_ = static_cast<size_t>(value);
+ remaining_ = length_decoder_.value();
// Make callback so consumer knows what is coming.
cb->OnStringStart(huffman_encoded_, remaining_);
}