Skip to content

Commit

Permalink
Fix use-after-destroy in epicsRefSnapshopCurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
JJL772 authored and mdavidsaver committed Aug 7, 2023
1 parent 04fcb7e commit eac2a8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/factory/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using std::string;
namespace epics { namespace pvData {


static std::vector<string> split(string commaSeparatedList) {
static std::vector<string> split(const string& commaSeparatedList) {
string::size_type numValues = 1;
string::size_type index=0;
while(true) {
Expand Down
6 changes: 3 additions & 3 deletions src/misc/reftrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit eac2a8e

Please sign in to comment.