]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Alex Rousskov <rousskov@measurement-factory.com>
authorAmos Jeffries <amosjeffries@squid-cache.org>
Wed, 14 Jul 2010 23:40:27 +0000 (17:40 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Wed, 14 Jul 2010 23:40:27 +0000 (17:40 -0600)
Fixed memory leaks related to Range requests.

HttpRequest::range field could be cleared without destroying HttpHdrRange
object in clientInterpretRequestHeaders().

The range field is essentially a cached value of the parsed Range header.
Managing the cache outside its owner object is a bad idea.

src/client_side_request.cc

index c00dfc834329ba2a344f4e3b582b97591222d73f..6e8d3a6e89c67bfcb0f437bc96420fafbfb35846 100644 (file)
@@ -830,7 +830,9 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
 
     /* ignore range header in non-GETs or non-HEADs */
     if (request->method == METHOD_GET || request->method == METHOD_HEAD) {
-        request->range = req_hdr->getRange();
+        // XXX: initialize if we got here without HttpRequest::parseHeader()
+        if (!request->range)
+            request->range = req_hdr->getRange();
 
         if (request->range) {
             request->flags.range = 1;
@@ -854,6 +856,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
     else {
         req_hdr->delById(HDR_RANGE);
         req_hdr->delById(HDR_REQUEST_RANGE);
+        delete request->range;
         request->range = NULL;
     }