Skip to content

Commit

Permalink
Fixes segv on free over new initialized stats
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoBiscosi committed Oct 30, 2024
1 parent 6d3dc27 commit 6adb699
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ZMQParserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ ZMQParserInterface::ZMQParserInterface(const char *endpoint,
ZMQParserInterface::~ZMQParserInterface() {
map<u_int32_t, nProbeStats *>::iterator it;

if (zmq_remote_stats) free(zmq_remote_stats);
if (zmq_remote_stats_shadow) free(zmq_remote_stats_shadow);
if (zmq_remote_stats) delete (zmq_remote_stats);
if (zmq_remote_stats_shadow) delete (zmq_remote_stats_shadow);
#ifdef NTOPNG_PRO
if (custom_app_maps) delete (custom_app_maps);
#endif
Expand Down Expand Up @@ -3186,7 +3186,7 @@ void ZMQParserInterface::setRemoteStats(nProbeStats *zrs) {
zmq_remote_initial_exported_flows = cumulative_zrs->num_flow_exports;

/* Swap values */
if (zmq_remote_stats_shadow) free(zmq_remote_stats_shadow);
if (zmq_remote_stats_shadow) delete (zmq_remote_stats_shadow);
zmq_remote_stats_shadow = zmq_remote_stats;
zmq_remote_stats = cumulative_zrs;

Expand Down

0 comments on commit 6adb699

Please sign in to comment.