From 4e05d2f6343bbb26599d19ae676850f019a0855a Mon Sep 17 00:00:00 2001 From: Tyshawn Date: Sun, 25 Jun 2023 07:12:45 +0000 Subject: [PATCH] [BUG.FIX] fix init table store core dump. --- src/storage/tablet/ob_table_store_util.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/storage/tablet/ob_table_store_util.cpp b/src/storage/tablet/ob_table_store_util.cpp index b4949d87ba..0a5617335b 100755 --- a/src/storage/tablet/ob_table_store_util.cpp +++ b/src/storage/tablet/ob_table_store_util.cpp @@ -159,13 +159,13 @@ int ObSSTableArray::inner_init( cnt_ = 0; sstable_array_ = nullptr; } else { - cnt_ = count; - sstable_array_ = static_cast(allocator.alloc(sizeof(ObSSTable *) * cnt_)); + sstable_array_ = static_cast(allocator.alloc(sizeof(ObSSTable *) * count)); if (OB_ISNULL(sstable_array_)) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("fail to allocate memory for sstable address array", K(ret), K_(cnt)); } - for (int64_t i = start_pos; OB_SUCC(ret) && i < start_pos + count; ++i) { + int64_t i = start_pos; + for (; OB_SUCC(ret) && i < start_pos + count; ++i) { ObITable *table = tables.at(i); if (OB_ISNULL(table)) { ret = OB_ERR_UNEXPECTED; @@ -178,10 +178,16 @@ int ObSSTableArray::inner_init( } } if (OB_FAIL(ret)) { + for (int64_t j = i - 2; j >= start_pos; --j) { + sstable_array_[j]->~ObSSTable(); + sstable_array_[j] = nullptr; + } if (nullptr != sstable_array_) { allocator.free(sstable_array_); sstable_array_ = nullptr; } + } else { + cnt_ = count; } } return ret;