Fix bug when reading already freed memory
[anna.git] / source / diameter / stack / Dictionary.cpp
index b94d46d..68f37c1 100644 (file)
@@ -41,8 +41,9 @@ LOGNOTICE(\
    trace += "\n";\
    anna::Logger::notice(trace, ANNA_FILE_LOCATION);\
 );\
+std::string name = found->getName();\
 pool.erase(pool.find(found->getId()));\
-poolNames.erase(poolNames.find(found->getName()));
+poolNames.erase(poolNames.find(name));
 
 
 //------------------------------------------------------------------------------
@@ -201,7 +202,7 @@ void Dictionary::addAvp(const Avp & avp) throw(anna::RuntimeException) {
     ITEM_OVERWRITE("avp", avp, a_avps, a_avpNames);
   }
 
-  if(found = getAvp(avp.getName())) {
+  if((found = getAvp(avp.getName()))) {
     if(!a_allowUpdates) {
       std::string s_ex = "Cannot add an avp with an existing name:\n";
       s_ex += avp.asString();