OSDN Git Service

Fix a crash when closing the native history.
authorPatrick Scott <phanna@android.com>
Mon, 30 Nov 2009 15:42:28 +0000 (10:42 -0500)
committerPatrick Scott <phanna@android.com>
Mon, 30 Nov 2009 16:33:28 +0000 (11:33 -0500)
The item for a given frame can be null when closing the history while reusing
the same WebView. If the item is null, no need to visit the children since they
will also not have a history item.

WebKit/android/jni/WebHistory.cpp

index 17aae52..0d469b4 100644 (file)
@@ -122,9 +122,12 @@ static void WebHistoryClose(JNIEnv* env, jobject obj, jint frame)
             // deleted parent.
             WebCore::HistoryItem* item = parent->childItemWithTarget(child->tree()->name());
             child->loader()->history()->setCurrentItem(item);
-            // Append the first child to the queue if it exists.
-            if (WebCore::Frame* f = child->tree()->firstChild())
-                frameQueue.append(f);
+            // Append the first child to the queue if it exists. If there is no
+            // item, then we do not need to traverse the children since there
+            // will be no parent history item.
+            WebCore::Frame* firstChild;
+            if (item && (firstChild = child->tree()->firstChild()))
+                frameQueue.append(firstChild);
             child = child->tree()->nextSibling();
             // If we don't have a sibling for this frame and the queue isn't
             // empty, use the next entry in the queue.