diff --git a/hipamd/src/hip_code_object.cpp b/hipamd/src/hip_code_object.cpp index 723b947010..b2635c6b7e 100644 --- a/hipamd/src/hip_code_object.cpp +++ b/hipamd/src/hip_code_object.cpp @@ -1215,8 +1215,10 @@ hipError_t StatCO::registerStatFunction(const void* hostFunction, Function* func if (functions_.find(hostFunction) != functions_.end()) { DevLogPrintfError("hostFunctionPtr: 0x%x already exists", hostFunction); + delete func; + } else { + functions_.insert(std::make_pair(hostFunction, func)); } - functions_.insert(std::make_pair(hostFunction, func)); return hipSuccess; }