aboutsummaryrefslogtreecommitdiffhomepage
path: root/absl/strings/internal
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2019-01-15 08:49:10 -0800
committerGravatar Alex Strelnikov <strel@google.com>2019-01-16 14:52:22 -0500
commit5e6a78131f7bd5940218462c07d88cdefdd75dbe (patch)
tree01600c5ecf63bb0b5434186aadba0a5a94a94e8b /absl/strings/internal
parent5eea0f713c14ac17788b83e496f11903f8e2bbb0 (diff)
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
Diffstat (limited to 'absl/strings/internal')
-rw-r--r--absl/strings/internal/str_format/parser.cc3
-rw-r--r--absl/strings/internal/str_format/parser_test.cc2
2 files changed, 4 insertions, 1 deletions
diff --git a/absl/strings/internal/str_format/parser.cc b/absl/strings/internal/str_format/parser.cc
index 5e3d0d0..10487f2 100644
--- a/absl/strings/internal/str_format/parser.cc
+++ b/absl/strings/internal/str_format/parser.cc
@@ -99,10 +99,11 @@ bool ConsumeConversion(string_view *src, UnboundConversion *conv,
// digit doesn't match the expected characters.
int num_digits = std::numeric_limits<int>::digits10;
for (;;) {
- if (ABSL_PREDICT_FALSE(pos == end || !num_digits)) break;
+ if (ABSL_PREDICT_FALSE(pos == end)) break;
c = *pos++;
if (!std::isdigit(c)) break;
--num_digits;
+ if (ABSL_PREDICT_FALSE(!num_digits)) break;
digits = 10 * digits + c - '0';
}
return digits;
diff --git a/absl/strings/internal/str_format/parser_test.cc b/absl/strings/internal/str_format/parser_test.cc
index ae40203..ff70575 100644
--- a/absl/strings/internal/str_format/parser_test.cc
+++ b/absl/strings/internal/str_format/parser_test.cc
@@ -246,6 +246,8 @@ TEST_F(ConsumeUnboundConversionTest, WidthAndPrecision) {
EXPECT_FALSE(Run("1000000000.999999999d"));
EXPECT_FALSE(Run("999999999.1000000000d"));
+ EXPECT_FALSE(Run("9999999999d"));
+ EXPECT_FALSE(Run(".9999999999d"));
}
TEST_F(ConsumeUnboundConversionTest, Flags) {