Reviewed by Simon Fraser.
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Mar 2009 22:14:52 +0000 (22:14 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Mar 2009 22:14:52 +0000 (22:14 +0000)
        Make TextTokenizer ASSERT that the buffer was freed
        https://bugs.webkit.org/show_bug.cgi?id=24684

        * loader/TextDocument.cpp:
        (WebCore::TextTokenizer::TextTokenizer):
        (WebCore::TextTokenizer::~TextTokenizer):
        (WebCore::TextTokenizer::finish):
          Make it clear by adding a ~TextTokenizer that finish() will always be called and the memory never leaked.

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

WebCore/ChangeLog
WebCore/loader/TextDocument.cpp

index fcaa763..9fa3601 100644 (file)
 
 2009-03-24  Eric Seidel  <eric@webkit.org>
 
+        Reviewed by Simon Fraser.
+
+        Make TextTokenizer ASSERT that the buffer was freed
+        https://bugs.webkit.org/show_bug.cgi?id=24684
+
+        * loader/TextDocument.cpp:
+        (WebCore::TextTokenizer::TextTokenizer):
+        (WebCore::TextTokenizer::~TextTokenizer):
+        (WebCore::TextTokenizer::finish):
+          Make it clear by adding a ~TextTokenizer that finish() will always be called and the memory never leaked.
+
+2009-03-24  Eric Seidel  <eric@webkit.org>
+
         Reviewed by Darin Adler.
 
         Fix case where lBreak.obj->isBR() when lBreak.obj was NULL
index 1e7ee3f..0d86c1b 100644 (file)
@@ -41,6 +41,7 @@ using namespace HTMLNames;
 class TextTokenizer : public Tokenizer {
 public:
     TextTokenizer(Document*);
+    virtual ~TextTokenizer();
     TextTokenizer(HTMLViewSourceDocument*);
 
     virtual void write(const SegmentedString&, bool appendData);
@@ -91,7 +92,13 @@ TextTokenizer::TextTokenizer(HTMLViewSourceDocument* doc)
     m_size = 254;
     m_buffer = static_cast<UChar*>(fastMalloc(sizeof(UChar) * m_size));
     m_dest = m_buffer;
-}    
+}
+
+TextTokenizer::~TextTokenizer()
+{
+    // finish() should have been called to prevent any leaks
+    ASSERT(!m_buffer);
+}
 
 void TextTokenizer::write(const SegmentedString& s, bool)
 {
@@ -157,7 +164,9 @@ void TextTokenizer::finish()
 {
     m_preElement = 0;
     fastFree(m_buffer);
-        
+    m_buffer = 0;
+    m_dest = 0;
+
     m_doc->finishedParsing();
 }