From 2dd66a22e122b2b059e9ee383f4d3e450bbf912e Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Fri, 16 Jan 2015 07:28:00 -0800 Subject: [PATCH] Fix mismatched new/free in rev.13849 Objects created with 'new' require 'delete'. Detected by Coverity Scan. Issue 1264386, 1264387. --- src/acl/Arp.cc | 19 +++++++------------ src/acl/Eui64.cc | 6 +++--- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/acl/Arp.cc b/src/acl/Arp.cc index dc5991ddb4..b9586c2bbe 100644 --- a/src/acl/Arp.cc +++ b/src/acl/Arp.cc @@ -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 diff --git a/src/acl/Eui64.cc b/src/acl/Eui64.cc index c7286d45e6..acb4bb7158 100644 --- a/src/acl/Eui64.cc +++ b/src/acl/Eui64.cc @@ -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; } } } -- 2.47.3