Fix use-after-destroy in epicsRefSnapshopCurrent

This commit is contained in:
JJL772
2023-08-06 21:30:32 -07:00
committed by mdavidsaver
parent 04fcb7e38f
commit eac2a8e70f
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -271,10 +271,10 @@ char* epicsRefSnapshotCurrent()
snap.update();
std::ostringstream strm;
strm<<snap;
const char *str = strm.str().c_str();
char *ret = (char*)malloc(strlen(str)+1);
std::string str = strm.str();
char *ret = (char*)malloc(str.length()+1);
if(ret)
strcpy(ret, str);
strcpy(ret, str.c_str());
return ret;
}catch(std::exception& e){
return epicsStrDup(e.what());