From 8eb920de3073bded959828bd4933affe577e7730 Mon Sep 17 00:00:00 2001 From: Yaroslav Miroshnychenko Date: Fri, 20 Apr 2012 13:24:53 +0200 Subject: Remove inconsistency between HistoryItem writing/reading Fixes inconsistent writing of HistoryItem formData for the case when formData is not null, but it gets flattened and saved as empty string. FormData identifier also gets written in that case, which creates problem on HistoryItem reading, when parser does not expect to meet form identifier after it reads zero as FormData size. Change-Id: I77cf00b5b2a0f2a7cf4355d1bc1b8d4830ac1afb --- Source/WebKit/android/jni/WebHistory.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Source') diff --git a/Source/WebKit/android/jni/WebHistory.cpp b/Source/WebKit/android/jni/WebHistory.cpp index b6972e4..6b71d0f 100644 --- a/Source/WebKit/android/jni/WebHistory.cpp +++ b/Source/WebKit/android/jni/WebHistory.cpp @@ -472,10 +472,13 @@ static void writeItem(WTF::Vector& vector, WebCore::HistoryItem* item) // Form data const WebCore::FormData* formData = item->formData(); if (formData) { - writeString(vector, formData->flattenToString()); - // save the identifier as it is not included in the flatten data - int64_t id = formData->identifier(); - vector.append((char*)&id, sizeof(int64_t)); + WTF::String flattenedFormData = formData->flattenToString(); + writeString(vector, flattenedFormData); + if (!flattenedFormData.isEmpty()) { + // save the identifier as it is not included in the flatten data + int64_t id = formData->identifier(); + vector.append((char*)&id, sizeof(int64_t)); + } } else writeString(vector, WTF::String()); // Empty constructor does not allocate a buffer. -- cgit v1.1