------------------------------------------------------------ revno: 11717 revision-id: squid3@treenet.co.nz-20121129112018-rrp7unxvfwluy455 parent: squid3@treenet.co.nz-20121129111711-5o2lx5x0szipnz2u committer: Amos Jeffries branch nick: 3.2 timestamp: Thu 2012-11-29 04:20:18 -0700 message: Various memory leaks in configuration parsing 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 the string handling in Squid but for now these still need fixing to avoid leaking memory. Detected by Coverity Scan. Issues 740430, 740432, 740439. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20121129112018-rrp7unxvfwluy455 # target_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # testament_sha1: 9eee04f41a09d1eea68eba70be14ca7c92233733 # timestamp: 2012-11-29 11:22:05 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # base_revision_id: squid3@treenet.co.nz-20121129111711-\ # 5o2lx5x0szipnz2u # # Begin patch === modified file 'src/adaptation/icap/Options.cc' --- src/adaptation/icap/Options.cc 2012-02-05 06:09:46 +0000 +++ src/adaptation/icap/Options.cc 2012-11-29 11:20:18 +0000 @@ -205,8 +205,11 @@ 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); + } } } === modified file 'src/cache_cf.cc' --- src/cache_cf.cc 2012-10-20 12:32:21 +0000 +++ src/cache_cf.cc 2012-11-29 11:20:18 +0000 @@ -540,6 +540,7 @@ cfg_filename = orig_cfg_filename; config_lineno = orig_config_lineno; + xfree(tmp_line); return err_count; } === modified file 'src/main.cc' --- src/main.cc 2012-06-04 11:10:49 +0000 +++ src/main.cc 2012-11-29 11:20:18 +0000 @@ -512,6 +512,7 @@ /** \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':