From d3f59fd91cffda1e25839f9b6c7dfb9466178797 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sun, 28 Sep 2003 06:05:08 +0000 Subject: [PATCH] Fix crash in XUL sort service -- unsigned ints are never less than 0... Bug 220516, r+sr=dbaron git-svn-id: svn://10.0.0.236/trunk@147390 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/xul/templates/src/nsXULSortService.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mozilla/content/xul/templates/src/nsXULSortService.cpp b/mozilla/content/xul/templates/src/nsXULSortService.cpp index 68f7a5f8389..e4071f11fff 100644 --- a/mozilla/content/xul/templates/src/nsXULSortService.cpp +++ b/mozilla/content/xul/templates/src/nsXULSortService.cpp @@ -1103,7 +1103,9 @@ XULSortServiceImpl::SortContainer(nsIContent *container, sortPtr sortInfo, nsCOMPtr tag; currentElement = numChildren; PRUint32 childIndex; - for (childIndex = numChildren - 1; childIndex >= 0; --childIndex) { + // childIndex is unsigned, so childIndex >= 0 would always test true + for (childIndex = numChildren; childIndex > 0; ) { + --childIndex; nsIContent *child = container->GetChildAt(childIndex); if (child->IsContentOfType(nsIContent::eXUL)) { @@ -1162,8 +1164,10 @@ XULSortServiceImpl::SortContainer(nsIContent *container, sortPtr sortInfo, sizeof(contentSortInfo*), testSortCallback, (void*)sortInfo); } - for (childIndex = numChildren - 1; childIndex >= 0; childIndex--) + // childIndex is unsigned, so childIndex >= 0 would always test true + for (childIndex = numChildren; childIndex > 0; ) { + --childIndex; nsIContent *child = container->GetChildAt(childIndex); if (child->IsContentOfType(nsIContent::eXUL)) {