diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-21 17:04:27 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-21 17:04:27 +0200 |
commit | 9f4701efaa2167e915518f01ef9d61185377196d (patch) | |
tree | 2b76cd8c5f4780be70bbec156f51ede7eb456cf6 /src | |
parent | 4226f9400d329467bf87b6bae2c9c57571250cb9 (diff) | |
download | lanes-9f4701efaa2167e915518f01ef9d61185377196d.tar.gz lanes-9f4701efaa2167e915518f01ef9d61185377196d.tar.bz2 lanes-9f4701efaa2167e915518f01ef9d61185377196d.zip |
Fix luaG_tostring to return a valid string even if the value is not convertible
Diffstat (limited to 'src')
-rw-r--r-- | src/compat.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compat.h b/src/compat.h index 0a02174..7049f3d 100644 --- a/src/compat.h +++ b/src/compat.h | |||
@@ -328,7 +328,7 @@ template <typename T> | |||
328 | { | 328 | { |
329 | size_t _len{ 0 }; | 329 | size_t _len{ 0 }; |
330 | char const* _str{ lua_tolstring(L_, idx_, &_len) }; | 330 | char const* _str{ lua_tolstring(L_, idx_, &_len) }; |
331 | return std::string_view{ _str, _len }; | 331 | return _str ? std::string_view{ _str, _len } : "<not a string>"; |
332 | } | 332 | } |
333 | 333 | ||
334 | [[nodiscard]] inline std::string_view luaG_checkstring(lua_State* const L_, int const idx_) | 334 | [[nodiscard]] inline std::string_view luaG_checkstring(lua_State* const L_, int const idx_) |