------------------------------------------------------------ revno: 12405 revision-id: squid3@treenet.co.nz-20121124034043-fihi03y5pn2ode74 parent: squid3@treenet.co.nz-20121124033934-tcw35w5l2594hpv7 committer: Amos Jeffries branch nick: 3.3 timestamp: Fri 2012-11-23 20:40:43 -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-20121124034043-fihi03y5pn2ode74 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: 9c1cddb7ff5820f88982400021902b729aa91fae # timestamp: 2012-11-24 03:44:00 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20121124033934-\ # tcw35w5l2594hpv7 # # Begin patch === modified file 'src/adaptation/icap/Options.cc' --- src/adaptation/icap/Options.cc 2012-08-31 16:57:39 +0000 +++ src/adaptation/icap/Options.cc 2012-11-24 03:40:43 +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 11:29:46 +0000 +++ src/cache_cf.cc 2012-11-24 03:40:43 +0000 @@ -594,6 +594,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-10-04 09:14:06 +0000 +++ src/main.cc 2012-11-24 03:40:43 +0000 @@ -543,6 +543,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':