Fix overflow found by GCC in basic_zstring_span::as_string_span().

This patch fixes an overflow that was identified with
strict overflow warnings enabled, and optimizations
turned on

Signed-off-by: “Rian <“rianquinn@gmail.com”>
This commit is contained in:
Rian Quinn 2016-10-28 00:45:54 -06:00 committed by Neil MacIntosh
parent 6cffe0d14c
commit f4486389b8

View File

@ -554,7 +554,8 @@ public:
constexpr string_span_type as_string_span() const noexcept
{
return span_.first(span_.size() - 1);
auto sz = span_.size();
return span_.first(sz <= 0 ? 0 : sz - 1);
}
constexpr string_span_type ensure_z() const noexcept { return gsl::ensure_z(span_); }