Fix memory leak introduced by previous change to Agent_global.

Make Agent_global manage the lifetime of the name string
This commit is contained in:
Siu Chi Chan
2019-03-09 13:50:26 -05:00
committed by Aaron Enye Shi
vanhempi 00d24d254d
commit bf1d48bf78
2 muutettua tiedostoa jossa 36 lisäystä ja 4 poistoa
+2 -4
Näytä tiedosto
@@ -341,10 +341,8 @@ inline hsa_status_t copy_agent_global_variables(hsa_executable_t, hsa_agent_t ag
hsa_executable_symbol_get_info(x, HSA_EXECUTABLE_SYMBOL_INFO_TYPE, &t);
if (t == HSA_SYMBOL_KIND_VARIABLE) {
Agent_global tmp = {nullptr, address(x), size(x)};
tmp.name = (char *) malloc(sizeof(name(x).c_str()));
strcpy(tmp.name, name(x).c_str());
static_cast<Container*>(out)->push_back(tmp);
Agent_global tmp(name(x).c_str(), address(x), size(x));
static_cast<Container*>(out)->push_back(std::move(tmp));
track(static_cast<Container*>(out)->back(),agent);
}