Change RELEASE_ASSERT in DocumentWriter::addData to ASSERT and early return
https://bugs.webkit.org/show_bug.cgi?id=199756
<rdar://problem/51554775>

Patch by Alex Christensen <achristensen@webkit.org> on 2019-07-12
Reviewed by Brady Eidson.

Attempts to reach this assertion were unsuccessful, but sometimes this assertion crashes.
Let's change it to an early return to prevent crashes.

* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::addData):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@247399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 956a97c..3d225fd 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
+2019-07-12  Alex Christensen  <achristensen@webkit.org>
+
+        Change RELEASE_ASSERT in DocumentWriter::addData to ASSERT and early return
+        https://bugs.webkit.org/show_bug.cgi?id=199756
+        <rdar://problem/51554775>
+
+        Reviewed by Brady Eidson.
+
+        Attempts to reach this assertion were unsuccessful, but sometimes this assertion crashes.
+        Let's change it to an early return to prevent crashes.
+
+        * loader/DocumentWriter.cpp:
+        (WebCore::DocumentWriter::addData):
+
 2019-07-12  Justin Fan  <justin_fan@apple.com>
 
         [WebGPU] Move error scopes out of GPUDevice for more portable error generation
diff --git a/Source/WebCore/loader/DocumentWriter.cpp b/Source/WebCore/loader/DocumentWriter.cpp
index 9f5903f..d16d805 100644
--- a/Source/WebCore/loader/DocumentWriter.cpp
+++ b/Source/WebCore/loader/DocumentWriter.cpp
@@ -237,7 +237,10 @@
 {
     // FIXME: Change these to ASSERT once https://bugs.webkit.org/show_bug.cgi?id=80427 has been resolved.
     RELEASE_ASSERT(m_state != State::NotStarted);
-    RELEASE_ASSERT(m_state != State::Finished);
+    if (m_state == State::Finished) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
     ASSERT(m_parser);
     m_parser->appendBytes(*this, bytes, length);
 }