From: Joshua Rogers Date: Sat, 20 Sep 2025 16:48:47 +0000 (+0000) Subject: SNMP: Match Var allocation/deallocation methods (#2183) X-Git-Tag: SQUID_7_2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d62e91795fedd3380db326e0ec9e5b7a1b85f767;p=thirdparty%2Fsquid.git 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. --- 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; }