]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix mismatched new/free in rev.13849
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 16 Jan 2015 15:28:00 +0000 (07:28 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 16 Jan 2015 15:28:00 +0000 (07:28 -0800)
Objects created with 'new' require 'delete'.

  Detected by Coverity Scan. Issue 12643861264387.

src/acl/Arp.cc
src/acl/Eui64.cc

index dc5991ddb421a73453181706b9b7042592af2d59..b9586c2bbe19339f4334771a40d5e811763960c7 100644 (file)
@@ -82,14 +82,14 @@ aclParseArpData(const char *t)
 
     if (sscanf(t, "%[0-9a-fA-F:]", buf) != 1) {
         debugs(28, DBG_CRITICAL, "aclParseArpData: Bad ethernet address: '" << t << "'");
-        safe_free(q);
+        delete q;
         return NULL;
     }
 
     if (!q->decode(buf)) {
         debugs(28, DBG_CRITICAL, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line);
         debugs(28, DBG_CRITICAL, "aclParseArpData: Ignoring invalid ARP acl entry: can't parse '" << buf << "'");
-        safe_free(q);
+        delete q;
         return NULL;
     }
 
@@ -102,17 +102,12 @@ aclParseArpData(const char *t)
 void
 ACLARP::parse()
 {
-    char *t = NULL;
-    Eui::Eui48 *q = NULL;
-
-    while ((t = strtokFile())) {
-        if ((q = aclParseArpData(t)) == NULL)
-            continue;
-
-        aclArpData.insert(*q);
-        safe_free(q);
+    while (const char *t = strtokFile()) {
+        if (Eui::Eui48 *q = aclParseArpData(t)) {
+            aclArpData.insert(*q);
+            delete q;
+        }
     }
-
 }
 
 int
index c7286d45e62068b0e0ed4f9ecd3818e181ac20aa..acb4bb71582107bf4c8a4942f4c338df465d059e 100644 (file)
@@ -54,14 +54,14 @@ aclParseEuiData(const char *t)
 
     if (sscanf(t, "%[0-9a-fA-F:]", buf) != 1) {
         debugs(28, DBG_CRITICAL, "aclParseEuiData: Bad EUI-64 address: '" << t << "'");
-        safe_free(q);
+        delete q;
         return NULL;
     }
 
     if (!q->decode(buf)) {
         debugs(28, DBG_CRITICAL, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line);
         debugs(28, DBG_CRITICAL, "aclParseEuiData: Ignoring invalid EUI-64 acl entry: can't parse '" << buf << "'");
-        safe_free(q);
+        delete q;
         return NULL;
     }
 
@@ -77,7 +77,7 @@ ACLEui64::parse()
     while (const char * t = strtokFile()) {
         if (Eui::Eui64 * q = aclParseEuiData(t)) {
             eui64Data.insert(*q);
-            safe_free(q);
+            delete q;
         }
     }
 }