Fix possible memory leak caused by failure path.

This commit is contained in:
Hooper9973
2024-08-05 12:23:06 +00:00
committed by ob-robot
parent 0fa70fd5ff
commit 96c50b57fd

View File

@ -265,16 +265,14 @@ int ObTabletMdsData::init_single_complex_addr(
fused_data_ptr = const_cast<mds::MdsDumpKV*>(mds_table_ptr); fused_data_ptr = const_cast<mds::MdsDumpKV*>(mds_table_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr); ObTabletObjLoadHelper::free(allocator, base_ptr);
} }
fused_data.addr_.set_mem_addr(0, sizeof(mds::MdsDumpKV));
}
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
fused_data_ptr = nullptr; fused_data_ptr = nullptr;
ObTabletObjLoadHelper::free(allocator, mds_table_ptr); ObTabletObjLoadHelper::free(allocator, mds_table_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr); ObTabletObjLoadHelper::free(allocator, base_ptr);
} else {
fused_data.addr_.set_mem_addr(0, sizeof(mds::MdsDumpKV));
} }
}
return ret; return ret;
} }
@ -305,16 +303,14 @@ int ObTabletMdsData::init_single_complex_addr(
fused_data_ptr = const_cast<share::ObTabletAutoincSeq*>(mds_table_ptr); fused_data_ptr = const_cast<share::ObTabletAutoincSeq*>(mds_table_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr); ObTabletObjLoadHelper::free(allocator, base_ptr);
} }
fused_data.addr_.set_mem_addr(0, sizeof(share::ObTabletAutoincSeq));
}
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
fused_data_ptr = nullptr; fused_data_ptr = nullptr;
ObTabletObjLoadHelper::free(allocator, mds_table_ptr); ObTabletObjLoadHelper::free(allocator, mds_table_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr); ObTabletObjLoadHelper::free(allocator, base_ptr);
} else {
fused_data.addr_.set_mem_addr(0, sizeof(share::ObTabletAutoincSeq));
} }
}
return ret; return ret;
} }
@ -361,11 +357,10 @@ int ObTabletMdsData::init_single_complex_addr(
} else { } else {
fused_data.addr_.set_mem_addr(0, sizeof(ObTabletDumpedMediumInfo)); fused_data.addr_.set_mem_addr(0, sizeof(ObTabletDumpedMediumInfo));
} }
}
// always free medium info list after usage // always free medium info list after usage
ObTabletObjLoadHelper::free(allocator, mds_table_ptr); ObTabletObjLoadHelper::free(allocator, mds_table_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr); ObTabletObjLoadHelper::free(allocator, base_ptr);
}
return ret; return ret;
} }
@ -850,10 +845,7 @@ int ObTabletMdsData::init_single_mds_dump_kv(
} }
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
if (nullptr != kv.ptr_) { ObTabletObjLoadHelper::free(allocator, kv.ptr_);
allocator.free(kv.ptr_);
kv.ptr_ = nullptr;
}
} }
return ret; return ret;
@ -1026,9 +1018,7 @@ int ObTabletMdsData::load_mds_dump_kv(
} }
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
if (nullptr != ptr) { ObTabletObjLoadHelper::free(allocator, ptr);
allocator.free(ptr);
}
} else { } else {
kv = ptr; kv = ptr;
} }
@ -1080,9 +1070,7 @@ int ObTabletMdsData::load_medium_info_list(
} }
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
if (nullptr != ptr) { ObTabletObjLoadHelper::free(allocator, ptr);
allocator.free(ptr);
}
} else { } else {
medium_info_list = ptr; medium_info_list = ptr;
} }
@ -1136,9 +1124,7 @@ int ObTabletMdsData::load_auto_inc_seq(
} }
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
if (nullptr != ptr) { ObTabletObjLoadHelper::free(allocator, ptr);
allocator.free(ptr);
}
} else { } else {
auto_inc_seq = ptr; auto_inc_seq = ptr;
} }
@ -1188,9 +1174,7 @@ int ObTabletMdsData::read_medium_info(
} }
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
if (nullptr != info) { ObTabletObjLoadHelper::free(allocator, info);
allocator.free(info);
}
} }
} }
} }