From 9f4701efaa2167e915518f01ef9d61185377196d Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 21 Jun 2024 17:04:27 +0200 Subject: Fix luaG_tostring to return a valid string even if the value is not convertible --- src/compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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 { size_t _len{ 0 }; char const* _str{ lua_tolstring(L_, idx_, &_len) }; - return std::string_view{ _str, _len }; + return _str ? std::string_view{ _str, _len } : ""; } [[nodiscard]] inline std::string_view luaG_checkstring(lua_State* const L_, int const idx_) -- cgit v1.2.3-55-g6feb