]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix memory leak regression in SNMP from rev.13274
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 13 Feb 2014 22:22:35 +0000 (11:22 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 13 Feb 2014 22:22:35 +0000 (11:22 +1300)
Variable "name" going out of scope leaks the storage it points to if any
of the parse was done by incomplete.

 Detected by Coverity Scan. Issue 1174204.

src/snmp_core.cc

index 9c39f0ccb3295fa53c86769912c2a9d48f7f48c9..e55fc4d0f828a2fc5d57b3b09e3966fd093647c1 100644 (file)
@@ -965,13 +965,14 @@ snmpCreateOidFromStr(const char *str, oid **name, int *nl)
         *name = (oid*)xrealloc(*name, sizeof(oid) * ((*nl) + 1));
         (*name)[*nl] = atoi(s); // stops at the '.' delimiter
         ++(*nl);
-        // exit with true when teh last octet has been parsed
+        // exit with true when the last octet has been parsed
         if (s[len] == '\0')
             return true;
         s += len+1;
     }
 
     // if we aborted before the lst octet was found, return false.
+    safe_free(name);
     return false;
 }