Prevent memory leaks when cloning Range requests.
HttpRequest::range field was set to a new HttpHdrRange object twice:
once in HttpRequest::clone() and once in HttpRequest::hdrCacheInit()
called from clone().
Polished HttpReply::clone() to make sure HttpReply::hdrCacheInit()
does not use uninitialized HttpReply::sline field and to prevent
benign double-initialization of HttpReply::keep_alive.
HttpReply::clone() const
{
HttpReply *rep = new HttpReply();
+ rep->sline = sline; // used in hdrCacheInit() call below
rep->header.append(&header);
rep->hdrCacheInit();
rep->hdr_sz = hdr_sz;
rep->body_pipe = body_pipe;
rep->protocol = protocol;
- rep->sline = sline;
- rep->keep_alive = keep_alive;
+ // keep_alive is handled in hdrCacheInit()
return rep;
}
// urlPath handled in ctor
copy->canonical = canonical ? xstrdup(canonical) : NULL;
- copy->range = range ? new HttpHdrRange(*range) : NULL;
+ // range handled in hdrCacheInit()
copy->ims = ims;
copy->imslen = imslen;
copy->max_forwards = max_forwards;
{
HttpMsg::hdrCacheInit();
+ assert(!range);
range = header.getRange();
}