Permalink
Browse files

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
  • Loading branch information...
1 parent ac9cca5 commit 5285073383719631e742dcc5ac0aa84ea330c1ba Yaroslav Miroshnychenko committed with Whitehawkx Apr 20, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 Source/WebKit/android/jni/WebHistory.cpp
@@ -472,10 +472,13 @@ static void writeItem(WTF::Vector<char>& 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.

0 comments on commit 5285073

Please sign in to comment.