]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: fix minor memory leak in squid.conf parsing
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 8 Aug 2016 23:34:31 +0000 (11:34 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 8 Aug 2016 23:34:31 +0000 (11:34 +1200)
 Detected by Coverity Scan. Issue 1154224

src/log/Config.cc

index 894982db495241e89ded99fd6b0a069c55e43245..a60c4bfdd825df05beae4673e2582835b20ff123 100644 (file)
@@ -19,13 +19,15 @@ Log::LogConfig::parseFormats()
 {
     char *name, *def;
 
-    if ((name = ConfigParser::NextToken()) == NULL)
+    if (!(name = ConfigParser::NextToken())) {
         self_destruct();
+    }
 
     ::Format::Format *nlf = new ::Format::Format(name);
 
     ConfigParser::EnableMacros();
-    if ((def = ConfigParser::NextQuotedOrToEol()) == NULL) {
+    if (!(def = ConfigParser::NextQuotedOrToEol())) {
+        delete nlf;
         self_destruct();
         return;
     }
@@ -34,6 +36,7 @@ Log::LogConfig::parseFormats()
     debugs(3, 2, "Log Format for '" << name << "' is '" << def << "'");
 
     if (!nlf->parse(def)) {
+        delete nlf;
         self_destruct();
         return;
     }