Fix memory leak introduced by previous change to Agent_global.

Make Agent_global manage the lifetime of the name string
Esse commit está contido em:
Siu Chi Chan authored and Aaron Enye Shi committed 2019-03-11 19:51:32 +00:00
1 pai 00d24d254d
commit bf1d48bf78
2 files changed
+36 -4

No files matched your search

+2 -4
Ver Arquivo
@@ -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);
}