From 3497dbfa193243ebf09de9074fa36e78cb1e14f7 Mon Sep 17 00:00:00 2001 From: saltonz Date: Wed, 28 Jun 2023 14:42:17 +0000 Subject: [PATCH] [bugfix] fix core on table store deserialize fail --- src/storage/tablet/ob_table_store_util.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/storage/tablet/ob_table_store_util.cpp b/src/storage/tablet/ob_table_store_util.cpp index 08a81ca0ab..4ba3324aca 100755 --- a/src/storage/tablet/ob_table_store_util.cpp +++ b/src/storage/tablet/ob_table_store_util.cpp @@ -263,6 +263,7 @@ int ObSSTableArray::deserialize( const int64_t ptr_array_size = sizeof(ObSSTable *) * cnt_; const int64_t obj_array_size = sizeof(ObSSTable) * cnt_; char *buff = nullptr; + int64_t deserialized_cnt = 0; if (OB_ISNULL(buff = static_cast(allocator.alloc(ptr_array_size + obj_array_size)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("fail to allocate memory for sstable array", K(ret), K_(cnt), K(ptr_array_size), K(obj_array_size)); @@ -273,14 +274,23 @@ int ObSSTableArray::deserialize( sstable_array_[i] = obj_array + i; if (OB_FAIL(sstable_array_[i]->deserialize(allocator, buf, data_len, pos))) { LOG_WARN("fail to deserialized sstable address", K(ret)); + } else { + ++deserialized_cnt; } } } if (OB_FAIL(ret)) { + for (int64_t i = 0; i < deserialized_cnt; ++i) { + ObSSTable *des_sstable = sstable_array_[i]; + if (nullptr != des_sstable) { + des_sstable->~ObSSTable(); + } + } if (nullptr != sstable_array_) { allocator.free(sstable_array_); sstable_array_ = nullptr; } + cnt_ = 0; } else { is_inited_ = true; }