Commit 45e3e58d authored by Alexandre Savard's avatar Alexandre Savard

#10795: fix sipaccount deserialisation broken

parent fdd135d5
......@@ -93,8 +93,7 @@ typedef std::map<std::string, YamlNode*> Mapping;
void MappingNode::setKeyValue(const std::string &key, YamlNode *value)
{
Mapping::iterator it = map_.end();
map_.insert(it, std::pair<std::string, YamlNode *>(key, value));
map_[key] = value;
}
void MappingNode::removeKeyValue(const std::string &key)
......@@ -107,6 +106,8 @@ YamlNode *MappingNode::getValue(const std::string &key) const
{
Mapping::const_iterator it = map_.find(key);
if (it != map_.end())
return it->second;
else
......@@ -125,19 +126,23 @@ void MappingNode::getValue(const std::string &key, bool *b) const
void MappingNode::getValue(const std::string &key, int *i) const
{
ScalarNode *node = static_cast<ScalarNode*>(getValue(key));
if (!node)
ScalarNode *node = dynamic_cast<ScalarNode*>(getValue(key));
if (!node) {
ERROR("node %s not found", key.c_str());
return;
}
*i = std::atoi(node->getValue().c_str());
}
void MappingNode::getValue(const std::string &key, std::string *v) const
{
ScalarNode *node = static_cast<ScalarNode*>(getValue(key));
ScalarNode *node = dynamic_cast<ScalarNode*>(getValue(key));
if (!node)
if (!node) {
ERROR("node %s not found", key.c_str());
return;
}
*v = node->getValue();
}
......@@ -146,7 +151,7 @@ void MappingNode::getValue(const std::string &key, std::string *v) const
void MappingNode::deleteChildNodes()
{
for (Mapping::iterator it = map_.begin(); it != map_.end(); ++it) {
YamlNode *yamlNode = static_cast<YamlNode *>(it->second);
YamlNode *yamlNode = dynamic_cast<YamlNode *>(it->second);
if (!yamlNode)
continue;
......@@ -155,21 +160,21 @@ void MappingNode::deleteChildNodes()
case DOCUMENT:
break;
case SEQUENCE: {
SequenceNode *sequence = static_cast<SequenceNode *>(yamlNode);
SequenceNode *sequence = dynamic_cast<SequenceNode *>(yamlNode);
sequence->deleteChildNodes();
delete sequence;
sequence = NULL;
}
break;
case MAPPING: {
MappingNode *mapping = static_cast<MappingNode *>(yamlNode);
MappingNode *mapping = dynamic_cast<MappingNode *>(yamlNode);
mapping->deleteChildNodes();
delete mapping;
mapping = NULL;
}
break;
case SCALAR: {
ScalarNode *scalar = static_cast<ScalarNode *>(yamlNode);
ScalarNode *scalar = dynamic_cast<ScalarNode *>(yamlNode);
delete scalar;
scalar = NULL;
}
......
......@@ -33,6 +33,7 @@
#include "../global.h"
#include "sfl_config.h"
#include "yamlnode.h"
#include "logger.h"
#include <cstdio>
namespace Conf {
......@@ -258,6 +259,7 @@ void YamlParser::processScalar(YamlNode *topNode)
break;
case MAPPING:
((MappingNode *)(topNode))->addNode(sclr);
break;
case SCALAR:
default:
break;
......
......@@ -2611,8 +2611,9 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
Sequence::const_iterator ip2ip = std::find_if(seq->begin(), seq->end(), isIP2IP);
if (ip2ip != seq->end()) {
MappingNode *node = dynamic_cast<MappingNode*>(*ip2ip);
if (node)
accountMap_[SIPAccount::IP2IP_PROFILE]->unserialize(node);
if (node) {
accountMap_[SIPAccount::IP2IP_PROFILE]->unserialize(*node);
}
}
// Initialize default UDP transport according to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment