Leaks seen in RenderRegion::setRenderBoxRegionInfo on Leaks bot
authormihnea@adobe.com <mihnea@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Nov 2011 21:14:53 +0000 (21:14 +0000)
committermihnea@adobe.com <mihnea@adobe.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Nov 2011 21:14:53 +0000 (21:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=71259

Reviewed by Darin Adler.

Leak fixes covered by existing tests.

* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::logicalWidthChangedInRegions):
The RenderBoxRegionInfo taken out of RenderRegion must be deleted on all code paths.
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::removeRenderBoxRegionInfo):
The RenderBoxRegionInfo map owns the values, therefore, when values are removed from map
they must also be deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@99467 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderRegion.cpp

index bd17824..9370bc5 100755 (executable)
@@ -1,3 +1,20 @@
+2011-11-07  Mihnea Ovidenie  <mihnea@adobe.com>
+
+        Leaks seen in RenderRegion::setRenderBoxRegionInfo on Leaks bot
+        https://bugs.webkit.org/show_bug.cgi?id=71259
+
+        Reviewed by Darin Adler.
+
+        Leak fixes covered by existing tests.
+
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::logicalWidthChangedInRegions):
+        The RenderBoxRegionInfo taken out of RenderRegion must be deleted on all code paths.
+        * rendering/RenderRegion.cpp:
+        (WebCore::RenderRegion::removeRenderBoxRegionInfo):
+        The RenderBoxRegionInfo map owns the values, therefore, when values are removed from map
+        they must also be deleted.
+
 2011-11-07  Adam Barth  <abarth@webkit.org>
 
         iframe sandbox treats vertical tab as a valid delimiter
index 577e956..0c33fd7 100644 (file)
@@ -658,16 +658,17 @@ bool RenderFlowThread::logicalWidthChangedInRegions(const RenderBlock* block, La
         if (!oldInfo)
             continue;
 
+        LayoutUnit oldLogicalWidth = oldInfo->logicalWidth();
+        delete oldInfo;
+
         RenderBoxRegionInfo* newInfo = block->renderBoxRegionInfo(region, offsetFromLogicalTopOfFirstPage);
-        if (!newInfo || newInfo->logicalWidth() != oldInfo->logicalWidth()) {
-            delete oldInfo;
+        if (!newInfo || newInfo->logicalWidth() != oldLogicalWidth)
             return true;
-        }
-        
+
         if (region == endRegion)
             break;
     }
-    
+
     return false;
 }
 
index fe60f69..f57393a 100644 (file)
@@ -224,7 +224,7 @@ RenderBoxRegionInfo* RenderRegion::takeRenderBoxRegionInfo(const RenderBox* box)
 
 void RenderRegion::removeRenderBoxRegionInfo(const RenderBox* box)
 {
-    m_renderBoxRegionInfo.remove(box);
+    delete m_renderBoxRegionInfo.take(box);
 }
 
 void RenderRegion::deleteAllRenderBoxRegionInfo()