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-27 23:45:54 -07:00
committed by Neil MacIntosh
parent 6cffe0d14c
commit f4486389b8
+2 -1
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_); }