mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
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:
parent
6cffe0d14c
commit
f4486389b8
@ -554,7 +554,8 @@ public:
|
|||||||
|
|
||||||
constexpr string_span_type as_string_span() const noexcept
|
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_); }
|
constexpr string_span_type ensure_z() const noexcept { return gsl::ensure_z(span_); }
|
||||||
|
Loading…
Reference in New Issue
Block a user