Prevent memory leaks when interpreting Range requests. HttpRequest::range field could be set to a new HttpHdrRange object twice: once in clientInterpretRequestHeaders() and once in HttpRequest::hdrCacheInit() called from HttpRequest::parseHeader(). 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. === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2009-04-28 23:00:49 +0000 +++ src/client_side_request.cc 2010-02-04 18:59:23 +0000 @@ -680,7 +680,9 @@ /* 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; @@ -704,6 +706,7 @@ else { req_hdr->delById(HDR_RANGE); req_hdr->delById(HDR_REQUEST_RANGE); + delete request->range; // if got here after HttpRequest::parseHeader() request->range = NULL; }