Bugfix: net tracer memory corruption issue - missing copy ctor/assignment

This commit is contained in:
Matthias Köfferlein 2018-09-01 21:26:29 +02:00
parent f0f3025f9f
commit e47a0966bd
2 changed files with 43 additions and 0 deletions

View File

@ -148,6 +148,39 @@ NetTracerData::NetTracerData ()
// .. nothing yet ..
}
NetTracerData::NetTracerData (const NetTracerData &other)
: m_next_log_layer (0)
{
operator= (other);
}
NetTracerData &
NetTracerData::operator= (const NetTracerData &other)
{
if (this != &other) {
for (std::map <unsigned int, NetTracerLayerExpression *>::const_iterator l = m_log_layers.begin (); l != m_log_layers.end (); ++l) {
delete l->second;
}
m_log_layers.clear ();
for (std::map <unsigned int, NetTracerLayerExpression *>::const_iterator l = other.m_log_layers.begin (); l != other.m_log_layers.end (); ++l) {
m_log_layers.insert (std::make_pair (l->first, new NetTracerLayerExpression (*l->second)));
}
m_next_log_layer = other.m_next_log_layer;
m_connections = other.m_connections;
m_original_layers = other.m_original_layers;
m_connection_graph = other.m_connection_graph;
m_log_connection_graph = other.m_log_connection_graph;
m_requires_booleans = other.m_requires_booleans;
m_symbols = other.m_symbols;
}
return *this;
}
NetTracerData::~NetTracerData ()
{
for (std::map <unsigned int, NetTracerLayerExpression *>::const_iterator l = m_log_layers.begin (); l != m_log_layers.end (); ++l) {

View File

@ -487,6 +487,16 @@ public:
*/
~NetTracerData ();
/**
* @brief Copy constructor
*/
NetTracerData (const NetTracerData &other);
/**
* @brief Assignment
*/
NetTracerData &operator= (const NetTracerData &other);
/**
* @brief Register a logical layer
*