Prevent serialization after being destroyed
Bug: 5246900
Change-Id: Ic0be139b26e1b52203b8d0286c12175df6a1a46c
diff --git a/core/java/android/webkit/ViewStateSerializer.java b/core/java/android/webkit/ViewStateSerializer.java
index 0fc76fa..5f91ed3 100644
--- a/core/java/android/webkit/ViewStateSerializer.java
+++ b/core/java/android/webkit/ViewStateSerializer.java
@@ -36,11 +36,15 @@
static boolean serializeViewState(OutputStream stream, WebView web)
throws IOException {
+ int baseLayer = web.getBaseLayer();
+ if (baseLayer == 0) {
+ return false;
+ }
DataOutputStream dos = new DataOutputStream(stream);
dos.writeInt(VERSION);
dos.writeInt(web.getContentWidth());
dos.writeInt(web.getContentHeight());
- return nativeSerializeViewState(web.getBaseLayer(), dos,
+ return nativeSerializeViewState(baseLayer, dos,
new byte[WORKING_STREAM_STORAGE]);
}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 5200b12..230234a 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -4311,6 +4311,9 @@
}
int getBaseLayer() {
+ if (mNativeClass == 0) {
+ return 0;
+ }
return nativeGetBaseLayer();
}