From: Christos Tsantilas Date: Fri, 1 Jul 2011 19:30:23 +0000 (+0300) Subject: Bug fixes: Multiple bugs in IdleConnList X-Git-Tag: take08~55^2~89 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ea9f7796fbaf5414c5cd7051d2c5e07833ae161;p=thirdparty%2Fsquid.git Bug fixes: Multiple bugs in IdleConnList - Inside IdleConnList::removeAt method the last element of the IdleConnList::theList_ array initialized with random memory - Inside IdleConnList::removeAt method if the IdleConnList::parent_ is NULL (ICAP connections pools) the size_ of the array is not decreased after element removed - Inside IdleConnList::closeN method, it removes always all elements from the list except the first one --- diff --git a/src/pconn.cc b/src/pconn.cc index 63dff19f2a..6d16b6ec1a 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -98,17 +98,17 @@ IdleConnList::removeAt(int index) return false; // shuffle the remaining entries to fill the new gap. - for (; index < size_ - 1; index++) + for (; index < size_ - 2; index++) theList_[index] = theList_[index + 1]; theList_[size_-1] = NULL; if (parent_) { parent_->noteConnectionRemoved(); + } - if (--size_ == 0) { - debugs(48, 3, HERE << "deleting " << hashKeyStr(&hash)); - delete this; - } + if (--size_ == 0) { + debugs(48, 3, HERE << "deleting " << hashKeyStr(&hash)); + delete this; } return true; } @@ -142,6 +142,7 @@ IdleConnList::closeN(size_t n) conn->close(); if (parent_) parent_->noteConnectionRemoved(); + ++index; } // shuffle the list N down. for (; index < (size_t)size_; index++) {