diff options
author | qarmin <mikrutrafal54@gmail.com> | 2019-10-11 11:39:40 +0200 |
---|---|---|
committer | qarmin <mikrutrafal54@gmail.com> | 2019-10-11 11:39:40 +0200 |
commit | 04c6579fd70ed669531113af08e45dc34ca717a9 (patch) | |
tree | ae4662eb961d53aebc8a72efcb8344b7df14e1c6 /core | |
parent | aad4d8648b4593b5edb479e85984730770e77c70 (diff) |
Don't use in some functions empty PoolByteArrays
Diffstat (limited to 'core')
-rw-r--r-- | core/variant_call.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 683c6882bf..40b944744b 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -553,7 +553,7 @@ struct _VariantCall { PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem); String s; - if (ba->size() >= 0) { + if (ba->size() > 0) { PoolByteArray::Read r = ba->read(); CharString cs; cs.resize(ba->size() + 1); @@ -569,7 +569,7 @@ struct _VariantCall { PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem); String s; - if (ba->size() >= 0) { + if (ba->size() > 0) { PoolByteArray::Read r = ba->read(); s.parse_utf8((const char *)r.ptr(), ba->size()); } @@ -580,14 +580,15 @@ struct _VariantCall { PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem); PoolByteArray compressed; - Compression::Mode mode = (Compression::Mode)(int)(*p_args[0]); + if (ba->size() > 0) { + Compression::Mode mode = (Compression::Mode)(int)(*p_args[0]); - compressed.resize(Compression::get_max_compressed_buffer_size(ba->size(), mode)); - int result = Compression::compress(compressed.write().ptr(), ba->read().ptr(), ba->size(), mode); - - result = result >= 0 ? result : 0; - compressed.resize(result); + compressed.resize(Compression::get_max_compressed_buffer_size(ba->size(), mode)); + int result = Compression::compress(compressed.write().ptr(), ba->read().ptr(), ba->size(), mode); + result = result >= 0 ? result : 0; + compressed.resize(result); + } r_ret = compressed; } @@ -615,6 +616,10 @@ struct _VariantCall { static void _call_PoolByteArray_hex_encode(Variant &r_ret, Variant &p_self, const Variant **p_args) { PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem); + if (ba->size() == 0) { + r_ret = String(); + return; + } PoolByteArray::Read r = ba->read(); String s = String::hex_encode_buffer(&r[0], ba->size()); r_ret = s; |