From: Francesco Chemolli Date: Wed, 12 Feb 2014 08:51:26 +0000 (+0100) Subject: Fix crash bug in HttpHeader::clean() X-Git-Tag: SQUID_3_5_0_1~375^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fda15157dd35919051d746bee7eb2f9217a5c45;p=thirdparty%2Fsquid.git Fix crash bug in HttpHeader::clean() --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 571072a9d3..de002db6bc 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -52,6 +52,10 @@ #include +/* XXX: the whole set of API managing the entries vector should be rethought + * after the parse4r-ng effort is complete. + */ + /* * On naming conventions: * @@ -437,8 +441,6 @@ HttpHeader::operator =(const HttpHeader &other) void HttpHeader::clean() { - HttpHeaderPos pos = HttpHeaderInitPos; - HttpHeaderEntry *e; assert(owner > hoNone && owner < hoEnd); debugs(55, 7, "cleaning hdr: " << this << " owner: " << owner); @@ -464,18 +466,19 @@ HttpHeader::clean() HttpHeaderStats[owner].busyDestroyedCount += entries.size() > 0; } // if (owner <= hoReply) - while ((e = getEntry(&pos))) { - /* tmp hack to try to avoid coredumps */ - + for (std::vector::iterator i = entries.begin(); i != entries.end(); ++i) { + HttpHeaderEntry *e = *i; + if (e == NULL) + continue; if (e->id < 0 || e->id >= HDR_ENUM_END) { - debugs(55, DBG_CRITICAL, "HttpHeader::clean BUG: entry[" << pos << "] is invalid (" << e->id << "). Ignored."); + debugs(55, DBG_CRITICAL, "BUG: invalid entry (" << e->id << "). Ignored."); } else { if (owner <= hoReply) HttpHeaderStats[owner].fieldTypeDistr.count(e->id); - /* yes, this deletion leaves us in an inconsistent state */ delete e; } } + entries.clear(); httpHeaderMaskInit(&mask, 0); len = 0;