From 7e22dfdd05dec9ac9fd61f5a2d4586f87200ea75 Mon Sep 17 00:00:00 2001 From: MaxStgs Date: Sat, 1 May 2021 23:01:23 +0500 Subject: [PATCH] Add PackedDataContainer data pointer check for non nullable (cherry picked from commit 94d0c4182ba8bd166c96c200573891ea76000738) --- core/packed_data_container.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index 3fcdf37b806..10dfe3aca3b 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -128,6 +128,7 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const { PoolVector::Read rd = data.read(); + ERR_FAIL_COND_V(!rd.ptr(), 0); const uint8_t *r = &rd[p_ofs]; uint32_t type = decode_uint32(r); @@ -158,6 +159,10 @@ int PackedDataContainer::_size(uint32_t p_ofs) const { Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, bool &err) const { PoolVector::Read rd = data.read(); + if (!rd.ptr()) { + err = true; + ERR_FAIL_COND_V(!rd.ptr(), Variant()); + } const uint8_t *r = &rd[p_ofs]; uint32_t type = decode_uint32(r);