Bug #180123. Crashes when resizing mail window with gtk2 build. Make sure to always return something from nsRegionGTK::GetRects(), even if the list of rects is empty. r=tor

This commit is contained in:
blizzard%redhat.com 2002-11-14 19:29:10 +00:00
Родитель 55bfd2c1c3
Коммит 27ed5b201a
1 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -275,15 +275,28 @@ NS_IMETHODIMP nsRegionGTK::GetRects(nsRegionRectSet **aRects)
gdk_region_get_rectangles(mRegion, &rects, &nrects);
if (!nrects)
// There are no rectangles in this region but we still need to
// return an empty structure.
if (!nrects) {
retval = (nsRegionRectSet *)nsMemory::Alloc(sizeof(nsRegionRectSet));
if (!retval)
return NS_ERROR_OUT_OF_MEMORY;
retval->mNumRects = 0;
retval->mRectsLen = 0;
retval->mArea = 0;
*aRects = retval;
return NS_OK;
}
// allocate space for our return values
retval = (nsRegionRectSet *)
nsMemory::Alloc(sizeof(nsRegionRectSet) +
(sizeof(nsRegionRect) * (nrects - 1)));
if (!retval)
return NS_ERROR_FAILURE;
return NS_ERROR_OUT_OF_MEMORY;
regionrect = &retval->mRects[0];
retval->mNumRects = nrects;