Don't use in some functions empty PoolByteArrays
This commit is contained in:
parent
aad4d8648b
commit
04c6579fd7
|
@ -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,6 +580,7 @@ struct _VariantCall {
|
|||
|
||||
PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
|
||||
PoolByteArray compressed;
|
||||
if (ba->size() > 0) {
|
||||
Compression::Mode mode = (Compression::Mode)(int)(*p_args[0]);
|
||||
|
||||
compressed.resize(Compression::get_max_compressed_buffer_size(ba->size(), mode));
|
||||
|
@ -587,7 +588,7 @@ struct _VariantCall {
|
|||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue