diff options
Diffstat (limited to 'absl/strings/internal/str_format/bind.cc')
-rw-r--r-- | absl/strings/internal/str_format/bind.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/absl/strings/internal/str_format/bind.cc b/absl/strings/internal/str_format/bind.cc index 5cf026b6..48a306d4 100644 --- a/absl/strings/internal/str_format/bind.cc +++ b/absl/strings/internal/str_format/bind.cc @@ -6,7 +6,7 @@ #include <string> namespace absl { -inline namespace lts_2018_12_18 { +inline namespace lts_2019_08_08 { namespace str_format_internal { namespace { @@ -26,12 +26,12 @@ class ArgContext { explicit ArgContext(absl::Span<const FormatArgImpl> pack) : pack_(pack) {} // Fill 'bound' with the results of applying the context's argument pack - // to the specified 'props'. We synthesize a BoundConversion by + // to the specified 'unbound'. We synthesize a BoundConversion by // lining up a UnboundConversion with a user argument. We also // resolve any '*' specifiers for width and precision, so after // this call, 'bound' has all the information it needs to be formatted. // Returns false on failure. - bool Bind(const UnboundConversion *props, BoundConversion *bound); + bool Bind(const UnboundConversion* unbound, BoundConversion* bound); private: absl::Span<const FormatArgImpl> pack_; @@ -54,7 +54,8 @@ inline bool ArgContext::Bind(const UnboundConversion* unbound, // "A negative field width is taken as a '-' flag followed by a // positive field width." force_left = true; - width = -width; + // Make sure we don't overflow the width when negating it. + width = -std::max(width, -std::numeric_limits<int>::max()); } } @@ -160,7 +161,7 @@ bool BindWithPack(const UnboundConversion* props, } std::string Summarize(const UntypedFormatSpecImpl format, - absl::Span<const FormatArgImpl> args) { + absl::Span<const FormatArgImpl> args) { typedef SummarizingConverter Converter; std::string out; { @@ -188,7 +189,7 @@ std::ostream& Streamable::Print(std::ostream& os) const { } std::string& AppendPack(std::string* out, const UntypedFormatSpecImpl format, - absl::Span<const FormatArgImpl> args) { + absl::Span<const FormatArgImpl> args) { size_t orig = out->size(); if (ABSL_PREDICT_FALSE(!FormatUntyped(out, format, args))) { out->erase(orig); @@ -227,5 +228,5 @@ int SnprintF(char* output, size_t size, const UntypedFormatSpecImpl format, } } // namespace str_format_internal -} // inline namespace lts_2018_12_18 +} // inline namespace lts_2019_08_08 } // namespace absl |