diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/variant_call.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 1b5ca9d3e5..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; @@ -591,9 +599,9 @@ struct _VariantCall { int buffer_size = (int)(*p_args[0]); - if (buffer_size < 0) { + if (buffer_size <= 0) { r_ret = decompressed; - ERR_FAIL_MSG("Decompression buffer size is less than zero."); + ERR_FAIL_MSG("Decompression buffer size must be greater than zero."); } decompressed.resize(buffer_size); |