Fixed memory leak in VirtualTap. Used unique_ptr instead of new/delete pair
This commit is contained in:
@@ -719,10 +719,11 @@ namespace ZeroTier {
|
|||||||
Mutex::Lock _l(_tcpconns_m);
|
Mutex::Lock _l(_tcpconns_m);
|
||||||
std::time_t current_ts = std::time(nullptr);
|
std::time_t current_ts = std::time(nullptr);
|
||||||
if (current_ts > last_housekeeping_ts + ZT_HOUSEKEEPING_INTERVAL) {
|
if (current_ts > last_housekeeping_ts + ZT_HOUSEKEEPING_INTERVAL) {
|
||||||
|
DEBUG_EXTRA();
|
||||||
// update managed routes (add/del from network stacks)
|
// update managed routes (add/del from network stacks)
|
||||||
ZeroTier::OneService *service = ((ZeroTier::OneService *)zt1ServiceRef);
|
ZeroTier::OneService *service = ((ZeroTier::OneService *)zt1ServiceRef);
|
||||||
if (service) {
|
if (service) {
|
||||||
std::vector<ZT_VirtualNetworkRoute> *managed_routes = service->getRoutes(this->_nwid);
|
std::unique_ptr<std::vector<ZT_VirtualNetworkRoute>> managed_routes(service->getRoutes(this->_nwid));
|
||||||
ZeroTier::InetAddress target_addr;
|
ZeroTier::InetAddress target_addr;
|
||||||
ZeroTier::InetAddress via_addr;
|
ZeroTier::InetAddress via_addr;
|
||||||
ZeroTier::InetAddress null_addr;
|
ZeroTier::InetAddress null_addr;
|
||||||
@@ -772,6 +773,7 @@ namespace ZeroTier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Clean up VirtualSocket objects
|
// TODO: Clean up VirtualSocket objects
|
||||||
last_housekeeping_ts = std::time(nullptr);
|
last_housekeeping_ts = std::time(nullptr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ namespace ZeroTier {
|
|||||||
* Timestamp of last run of housekeeping
|
* Timestamp of last run of housekeeping
|
||||||
* SEE: ZT_HOUSEKEEPING_INTERVAL in libzt.h
|
* SEE: ZT_HOUSEKEEPING_INTERVAL in libzt.h
|
||||||
*/
|
*/
|
||||||
std::time_t last_housekeeping_ts;
|
std::time_t last_housekeeping_ts = 0;
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* In these, we will call the stack's corresponding functions, this is */
|
/* In these, we will call the stack's corresponding functions, this is */
|
||||||
|
|||||||
Reference in New Issue
Block a user