]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug fixes: Multiple bugs in IdleConnList
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Fri, 1 Jul 2011 19:30:23 +0000 (22:30 +0300)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Fri, 1 Jul 2011 19:30:23 +0000 (22:30 +0300)
- 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

src/pconn.cc

index 63dff19f2a6427fdf873e7dd24566c6f9fb37255..6d16b6ec1a873428e0e9443a71a7dddc18e12b99 100644 (file)
@@ -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++) {