From c62da553cbc3581e68e9526474f46100afd2c87a Mon Sep 17 00:00:00 2001 From: qarmin Date: Fri, 11 Oct 2019 09:13:30 +0200 Subject: [PATCH] Don't use to_utf8() and to_ascii() on empty String --- core/variant_call.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 1b5ca9d3e5d2..a1b75266ffde 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -316,6 +316,10 @@ struct _VariantCall { static void _call_String_to_ascii(Variant &r_ret, Variant &p_self, const Variant **p_args) { String *s = reinterpret_cast(p_self._data._mem); + if (s->empty()) { + r_ret = PoolByteArray(); + return; + } CharString charstr = s->ascii(); PoolByteArray retval; @@ -331,6 +335,10 @@ struct _VariantCall { static void _call_String_to_utf8(Variant &r_ret, Variant &p_self, const Variant **p_args) { String *s = reinterpret_cast(p_self._data._mem); + if (s->empty()) { + r_ret = PoolByteArray(); + return; + } CharString charstr = s->utf8(); PoolByteArray retval;