]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Plugged two SNMP memory leaks.
authorhno <>
Wed, 13 Feb 2002 07:50:34 +0000 (07:50 +0000)
committerhno <>
Wed, 13 Feb 2002 07:50:34 +0000 (07:50 +0000)
  One small for the community string
  One larger (4K) for the eventual response

src/snmp_core.cc

index edf6076e634b8c2c021f7e380da6db44a350384e..a6da57457fc093e6f24db649165791598ee9524e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: snmp_core.cc,v 1.51 2001/08/30 09:51:40 hno Exp $
+ * $Id: snmp_core.cc,v 1.52 2002/02/13 00:50:34 hno Exp $
  *
  * DEBUG: section 49    SNMP support
  * AUTHOR: Glenn Chisholm
@@ -482,6 +482,7 @@ snmpHandleUdp(int sock, void *not_used)
        snmp_rq->outbuf = xmalloc(snmp_rq->outlen = SNMP_REQUEST_SIZE);
        xmemcpy(&snmp_rq->from, &from, sizeof(struct sockaddr_in));
        snmpDecodePacket(snmp_rq);
+       xfree(snmp_rq->outbuf);
        xfree(snmp_rq);
     } else {
        debug(49, 1) ("snmpHandleUdp: FD %d recvfrom: %s\n", sock, xstrerror());
@@ -523,6 +524,8 @@ snmpDecodePacket(snmp_request_t * rq)
            inet_ntoa(rq->from.sin_addr));
        snmp_free_pdu(PDU);
     }
+    if (Community)
+       free(Community);
 }
 
 /*
@@ -544,7 +547,6 @@ snmpConstructReponse(snmp_request_t * rq)
        snmp_build(&Session, RespPDU, rq->outbuf, &rq->outlen);
        sendto(rq->sock, rq->outbuf, rq->outlen, 0, (struct sockaddr *) &rq->from, sizeof(rq->from));
        snmp_free_pdu(RespPDU);
-       xfree(rq->outbuf);
     }
 }