Fix memory leak in hip_fatbin.cpp UncompressAndPopulateCodeObject (#1692)
Wrap amd_comgr_data_t item returned from action_data_get_data() in ComgrDataUniqueHandle to ensure it gets released.
This commit is contained in:
@@ -349,9 +349,10 @@ static bool UncompressAndPopulateCodeObject(
|
||||
LogError("Failed to get data unbundled code object");
|
||||
break;
|
||||
}
|
||||
comgr_helper::ComgrDataUniqueHandle item_handle(item);
|
||||
|
||||
size_t item_name_size = 0;
|
||||
if (auto comgr_status = amd::Comgr::get_data_name(item, &item_name_size, nullptr);
|
||||
if (auto comgr_status = amd::Comgr::get_data_name(item_handle.get(), &item_name_size, nullptr);
|
||||
comgr_status != AMD_COMGR_STATUS_SUCCESS) {
|
||||
LogError("Failed to get data size");
|
||||
break;
|
||||
@@ -359,14 +360,14 @@ static bool UncompressAndPopulateCodeObject(
|
||||
|
||||
std::string item_bundle_id(item_name_size, 0);
|
||||
if (auto comgr_status =
|
||||
amd::Comgr::get_data_name(item, &item_name_size, item_bundle_id.data());
|
||||
amd::Comgr::get_data_name(item_handle.get(), &item_name_size, item_bundle_id.data());
|
||||
comgr_status != AMD_COMGR_STATUS_SUCCESS) {
|
||||
LogError("Failed to get data");
|
||||
break;
|
||||
}
|
||||
|
||||
size_t item_size = 0;
|
||||
if (auto comgr_status = amd::Comgr::get_data(item, &item_size, nullptr);
|
||||
if (auto comgr_status = amd::Comgr::get_data(item_handle.get(), &item_size, nullptr);
|
||||
comgr_status != AMD_COMGR_STATUS_SUCCESS) {
|
||||
LogError("Failed to get data size");
|
||||
break;
|
||||
@@ -374,7 +375,7 @@ static bool UncompressAndPopulateCodeObject(
|
||||
|
||||
if (item_size > 0) {
|
||||
char* item_data = new char[item_size];
|
||||
if (auto comgr_status = amd::Comgr::get_data(item, &item_size, item_data);
|
||||
if (auto comgr_status = amd::Comgr::get_data(item_handle.get(), &item_size, item_data);
|
||||
comgr_status != AMD_COMGR_STATUS_SUCCESS) {
|
||||
LogError("Failed to get data");
|
||||
break;
|
||||
|
||||
Viittaa uudesa ongelmassa
Block a user