Handle invalid data more gracefully.
[WebKit-https.git] / Source / WebKit2 / UIProcess / mac / LegacySessionStateCoding.cpp
index 65ee2fa334f4dfa1dfae80b288b90755bf732e41..595cc60183b0d400e3aa98c13af2068b5a349474 100644 (file)
@@ -825,6 +825,9 @@ static void decodeFormData(HistoryEntryDataDecoder& decoder, HTTPBody& formData)
         HTTPBody::Element formDataElement;
         decodeFormDataElement(decoder, formDataElement);
 
+        if (!decoder.isValid())
+            return;
+
         formData.elements.append(std::move(formDataElement));
     }
 
@@ -846,6 +849,10 @@ static void decodeBackForwardTreeNode(HistoryEntryDataDecoder& decoder, FrameSta
         decoder >> childFrameState.urlString;
 
         decodeBackForwardTreeNode(decoder, childFrameState);
+
+        if (!decoder.isValid())
+            return;
+
         frameState.children.append(std::move(childFrameState));
     }
 
@@ -858,6 +865,9 @@ static void decodeBackForwardTreeNode(HistoryEntryDataDecoder& decoder, FrameSta
         String state;
         decoder >> state;
 
+        if (!decoder.isValid())
+            return;
+
         frameState.documentState.append(std::move(state));
     }