]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Various memory leaks in configuration parsing
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 17 Nov 2012 12:58:59 +0000 (05:58 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 17 Nov 2012 12:58:59 +0000 (05:58 -0700)
This lot are all small issues derived from allocating new memory and
assigning to a pointer already pointing at previous allocation, or
passing xstrdup() output to a caller which does not directly hold the
passed memory.
 Both cases will disappear once we clean up teh string handlign in Squid
but for now these still need fixing to avoid leaking memory.

 Detected by Coverity Scan. Issues 740430, 740432, 740439.

src/adaptation/icap/Options.cc
src/cache_cf.cc
src/main.cc

index c79273510745a49e8483c2f4cc47d31fc6df01a1..219589c1de21a976c3c79cf88e31b2c06a4315c8 100644 (file)
@@ -205,8 +205,11 @@ void Adaptation::Icap::Options::TransferList::parse(const String &buf, bool &fou
     while (strListGetItem(&buf, ',', &item, &ilen, &pos)) {
         if (ilen == 1 && *item == '*')
             foundStar = true;
-        else
-            add(xstrndup(item, ilen+1));
+        else {
+            const char *tmp = xstrndup(item, ilen+1);
+            add(tmp);
+            xfree(tmp);
+        }
     }
 }
 
index ed1f2192cecb62ee0a1ac700fdffceae99fe4b28..0464f7685c245f97f65be31d4a2d70956ec871bc 100644 (file)
@@ -594,6 +594,7 @@ parseOneConfigFile(const char *file_name, unsigned int depth)
     cfg_filename = orig_cfg_filename;
     config_lineno = orig_config_lineno;
 
+    xfree(tmp_line);
     return err_count;
 }
 
index 544fe2838ce06e4e2458df4db0cee21c7f7efa1d..128c8da2ebc0f7d5025cb5fb3ba359d35bfc7b81 100644 (file)
@@ -541,6 +541,7 @@ mainParseOptions(int argc, char *argv[])
             /** \par l
              * Stores the syslog facility name in global opt_syslog_facility
              * then performs actions for -s option. */
+            xfree(opt_syslog_facility); // ignore any previous options sent
             opt_syslog_facility = xstrdup(optarg);
 
         case 's':