From 4022971135dd49add83e867b6e4c0aaae4fe9aca Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Sat, 20 Sep 2025 16:48:47 +0000 Subject: [PATCH] SNMP: Match Var allocation/deallocation methods (#2183) Pdu::setVars() and Pdu::unpack() allocate variables with `new Var(...)`, but clearVars() freed them using snmp_var_free(). That skipped the `Var` destructor and mismatched the allocator. We hope that all Pdu::variables are allocated via Pdu class methods despite the presence of snmp_var_new() and snmp_var_clone() calls in low-level snmplib code. --- src/snmp/Pdu.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snmp/Pdu.cc b/src/snmp/Pdu.cc index cc90813d4d..4fbe850d6e 100644 --- a/src/snmp/Pdu.cc +++ b/src/snmp/Pdu.cc @@ -121,7 +121,7 @@ Snmp::Pdu::clearVars() while (var != nullptr) { variable_list* tmp = var; var = var->next_variable; - snmp_var_free(tmp); + delete static_cast(tmp); } variables = nullptr; } -- 2.47.3