diff --git a/src/ox/std/stringview.hpp b/src/ox/std/stringview.hpp index 6a2221e05..6fc955c61 100644 --- a/src/ox/std/stringview.hpp +++ b/src/ox/std/stringview.hpp @@ -104,13 +104,16 @@ constexpr ox::Result strToInt(StringViewCR str) noexcept { OX_ALLOW_UNSAFE_BUFFERS_BEGIN int total = 0; int multiplier = 1; + if (str.len() == 0) [[unlikely]] { + return Error{1, "Empty string passed to strToInt"}; + } for (auto i = static_cast(str.len()) - 1; i != -1; --i) { auto s = static_cast(i); if (str[s] >= '0' && str[s] <= '9') { total += (str[s] - '0') * multiplier; multiplier *= 10; } else { - return ox::Error(1); + return ox::Error{1}; } } return total;