diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-10-11 11:24:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-11 11:24:40 +0200 |
commit | 7f075e519abeefbe0aa1dc54a9711b94a4a8eebe (patch) | |
tree | 0bb3d16907d403302b86e0e9a516a69e17d6fc03 | |
parent | 197be41cca6f24798e542398437f5dc35923c2f1 (diff) | |
parent | c62da553cbc3581e68e9526474f46100afd2c87a (diff) |
Merge pull request #32741 from qarmin/fix_string_utf_ascii
Don't use to_utf8() and to_ascii() on empty String
-rw-r--r-- | core/variant_call.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 8a64ee4e2f..683c6882bf 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<String *>(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<String *>(p_self._data._mem); + if (s->empty()) { + r_ret = PoolByteArray(); + return; + } CharString charstr = s->utf8(); PoolByteArray retval; |