------------------------------------------------------------ revno: 13755 revision-id: squid3@treenet.co.nz-20150218041540-we99vbvq571y2jhf parent: squid3@treenet.co.nz-20150218041042-97gw06yoxv7f7e6d committer: Amos Jeffries branch nick: 3.5 timestamp: Tue 2015-02-17 20:15:40 -0800 message: Fix memory leaks in cachemgr.cgi URL parser Detected by Coverity Scan. Issue 1256164 ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20150218041540-we99vbvq571y2jhf # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: 6d63105b08b54c28fa3f5b7aa0689efc8fe5284a # timestamp: 2015-02-18 04:17:56 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20150218041042-\ # 97gw06yoxv7f7e6d # # Begin patch === modified file 'tools/cachemgr.cc' --- tools/cachemgr.cc 2015-01-13 09:13:49 +0000 +++ tools/cachemgr.cc 2015-02-18 04:15:40 +0000 @@ -980,7 +980,7 @@ cachemgr_request *req; char *s; - char *t; + char *t = NULL; char *q; if ((buf = read_post_request()) != NULL) @@ -1005,6 +1005,7 @@ req = (cachemgr_request *)xcalloc(1, sizeof(cachemgr_request)); for (s = strtok(buf, "&"); s != NULL; s = strtok(NULL, "&")) { + safe_free(t); t = xstrdup(s); if ((q = strchr(t, '=')) == NULL) @@ -1035,8 +1036,8 @@ req->workers = xstrdup(q); else if (0 == strcmp(t, "processes") && strlen(q)) req->processes = xstrdup(q); - safe_free(t); } + safe_free(t); if (req->server && !req->hostname) { char *p;