Bug 753665 - Fix possible corruption in the window parent chain. r=blassey
authorKartikaya Gupta <kgupta@mozilla.com>
Sat, 26 May 2012 11:06:25 -0400
changeset 95050 88787676b14a19cf8f5124407fa5e2c8a27ef604
parent 95049 d22c4f57daaf73720ae3a5e5ff17e19a74a0fdca
child 95051 20a421502a41c9c8c2f9c8c42bef2922d429b2ce
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersblassey
bugs753665
milestone15.0a1
Bug 753665 - Fix possible corruption in the window parent chain. r=blassey
widget/android/nsWindow.cpp
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -236,20 +236,20 @@ nsWindow::Create(nsIWidget *aParent,
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWindow::Destroy(void)
 {
     nsBaseWidget::mOnDestroyCalled = true;
 
-    for (PRUint32 i = 0; i < mChildren.Length(); ++i) {
+    while (mChildren.Length()) {
         // why do we still have children?
-        ALOG("### Warning: Destroying window %p and reparenting child %p to null!", (void*)this, (void*)mChildren[i]);
-        mChildren[i]->SetParent(nsnull);
+        ALOG("### Warning: Destroying window %p and reparenting child %p to null!", (void*)this, (void*)mChildren[0]);
+        mChildren[0]->SetParent(nsnull);
     }
 
     if (IsTopLevel())
         gTopLevelWindows.RemoveElement(this);
 
     if (mParent)
         mParent->mChildren.RemoveElement(this);