Export of internal Abseil changes.

--
4a492de32dd1e02c5c3600bfdb36da7af7855210 by Samuel Benzaquen <sbenza@google.com>:

Fix potential intergral overflow in the parser.

PiperOrigin-RevId: 229378698

--
c5d5385eff879a65582138febb44c79725baf582 by CJ Johnson <johnsoncj@google.com>:

Adds an explanatory comment over AbslHashValue(...) for InlinedVector

PiperOrigin-RevId: 229237373
GitOrigin-RevId: 4a492de32dd1e02c5c3600bfdb36da7af7855210
Change-Id: Iad9edfde23ab5af9001ce80e3d00a34be3d73815
This commit is contained in:
Abseil Team 2019-01-15 08:49:10 -08:00 committed by Alex Strelnikov
parent 5eea0f713c
commit 5e6a78131f
3 changed files with 8 additions and 1 deletions

View file

@ -1354,6 +1354,10 @@ bool operator>=(const InlinedVector<T, N, A>& a,
return !(a < b); return !(a < b);
} }
// AbslHashValue()
//
// Provides `absl::Hash` support for inlined vectors. You do not normally call
// this function directly.
template <typename Hash, typename TheT, size_t TheN, typename TheA> template <typename Hash, typename TheT, size_t TheN, typename TheA>
Hash AbslHashValue(Hash hash, const InlinedVector<TheT, TheN, TheA>& vec) { Hash AbslHashValue(Hash hash, const InlinedVector<TheT, TheN, TheA>& vec) {
auto p = vec.data(); auto p = vec.data();

View file

@ -99,10 +99,11 @@ bool ConsumeConversion(string_view *src, UnboundConversion *conv,
// digit doesn't match the expected characters. // digit doesn't match the expected characters.
int num_digits = std::numeric_limits<int>::digits10; int num_digits = std::numeric_limits<int>::digits10;
for (;;) { for (;;) {
if (ABSL_PREDICT_FALSE(pos == end || !num_digits)) break; if (ABSL_PREDICT_FALSE(pos == end)) break;
c = *pos++; c = *pos++;
if (!std::isdigit(c)) break; if (!std::isdigit(c)) break;
--num_digits; --num_digits;
if (ABSL_PREDICT_FALSE(!num_digits)) break;
digits = 10 * digits + c - '0'; digits = 10 * digits + c - '0';
} }
return digits; return digits;

View file

@ -246,6 +246,8 @@ TEST_F(ConsumeUnboundConversionTest, WidthAndPrecision) {
EXPECT_FALSE(Run("1000000000.999999999d")); EXPECT_FALSE(Run("1000000000.999999999d"));
EXPECT_FALSE(Run("999999999.1000000000d")); EXPECT_FALSE(Run("999999999.1000000000d"));
EXPECT_FALSE(Run("9999999999d"));
EXPECT_FALSE(Run(".9999999999d"));
} }
TEST_F(ConsumeUnboundConversionTest, Flags) { TEST_F(ConsumeUnboundConversionTest, Flags) {