]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SNMP: Match Var allocation/deallocation methods (#2183)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sat, 20 Sep 2025 16:48:47 +0000 (16:48 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 20 Sep 2025 16:50:23 +0000 (16:50 +0000)
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

index cc90813d4d4c941c740e377e78082785e89f8dd1..4fbe850d6ed31bd025ec3984746db4d16a6a4b8c 100644 (file)
@@ -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<Var*>(tmp);
     }
     variables = nullptr;
 }