From: Amos Jeffries Date: Thu, 13 Feb 2014 22:22:35 +0000 (+1300) Subject: Fix memory leak regression in SNMP from rev.13274 X-Git-Tag: SQUID_3_5_0_1~370 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e2de742cf4d2c8858542d7493177fff5a640f485;p=thirdparty%2Fsquid.git Fix memory leak regression in SNMP from rev.13274 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. --- diff --git a/src/snmp_core.cc b/src/snmp_core.cc index 9c39f0ccb3..e55fc4d0f8 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -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; }