Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Dec 31, 2023
1 parent eb9cdea commit 0d38ce0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void CConfigValue::defaultFrom(SConfigDefaultValue& ref) {
break;
}
case CONFIGDATATYPE_STR: {
if (!m_pData)
if (m_pData)
free(m_pData);
std::string str = std::any_cast<std::string>(ref.data);
m_pData = calloc(1, str.length() + 1);
Expand Down Expand Up @@ -131,7 +131,8 @@ void CConfigValue::setFrom(std::any value) {
break;
}
case CONFIGDATATYPE_STR: {
free(m_pData);
if (m_pData)
free(m_pData);
std::string str = std::any_cast<std::string>(value);
m_pData = calloc(1, str.length() + 1);
strncpy((char*)m_pData, str.c_str(), str.length());
Expand Down

0 comments on commit 0d38ce0

Please sign in to comment.