Title: [240896] trunk/Source/WTF
Revision
240896
Author
[email protected]
Date
2019-02-02 10:35:42 -0800 (Sat, 02 Feb 2019)

Log Message

Leak of WTF::StringImpl under SymbolImpl::createNullSymbol() (48 bytes) in com.apple.WebKit.WebContent running layout tests
<https://webkit.org/b/193291>
<rdar://problem/46655953>

Reviewed by Keith Miller.

* wtf/text/SymbolImpl.h:
(WTF::SymbolImpl::~SymbolImpl): Fix the leak by implementing the
class destructor that calls StringImpl::deref() on `m_owner`.
Two of the three constructors leak the StringImpl when setting
`m_owner`, so we need to balance that by manually calling
deref().

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (240895 => 240896)


--- trunk/Source/WTF/ChangeLog	2019-02-02 16:32:05 UTC (rev 240895)
+++ trunk/Source/WTF/ChangeLog	2019-02-02 18:35:42 UTC (rev 240896)
@@ -1,3 +1,18 @@
+2019-02-02  David Kilzer  <[email protected]>
+
+        Leak of WTF::StringImpl under SymbolImpl::createNullSymbol() (48 bytes) in com.apple.WebKit.WebContent running layout tests
+        <https://webkit.org/b/193291>
+        <rdar://problem/46655953>
+
+        Reviewed by Keith Miller.
+
+        * wtf/text/SymbolImpl.h:
+        (WTF::SymbolImpl::~SymbolImpl): Fix the leak by implementing the
+        class destructor that calls StringImpl::deref() on `m_owner`.
+        Two of the three constructors leak the StringImpl when setting
+        `m_owner`, so we need to balance that by manually calling
+        deref().
+
 2018-12-16  Darin Adler  <[email protected]>
 
         Convert additional String::format clients to alternative approaches

Modified: trunk/Source/WTF/wtf/text/SymbolImpl.h (240895 => 240896)


--- trunk/Source/WTF/wtf/text/SymbolImpl.h	2019-02-02 16:32:05 UTC (rev 240895)
+++ trunk/Source/WTF/wtf/text/SymbolImpl.h	2019-02-02 18:35:42 UTC (rev 240896)
@@ -116,6 +116,13 @@
         ASSERT(StringImpl::tailOffset<StringImpl*>() == OBJECT_OFFSETOF(SymbolImpl, m_owner));
     }
 
+    ~SymbolImpl()
+    {
+        if (m_owner != StringImpl::empty())
+            m_owner->deref();
+        m_owner = nullptr;
+    }
+
     // The pointer to the owner string should be immediately following after the StringImpl layout,
     // since we would like to align the layout of SymbolImpl to the one of BufferSubstring StringImpl.
     StringImpl* m_owner;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to