From fe49a5f005b8b6f535db9227d9b6a24b45212b46 Mon Sep 17 00:00:00 2001 From: Joe Steele Date: Wed, 18 Jun 2014 11:38:01 -0400 Subject: [PATCH] Avoid NPE in MessageOpenPgpView.handleError() E/AndroidRuntime(25655): FATAL EXCEPTION: main E/AndroidRuntime(25655): Process: com.fsck.k9, PID: 25655 E/AndroidRuntime(25655): java.lang.NullPointerException E/AndroidRuntime(25655): at com.fsck.k9.view.MessageOpenPgpView.handleError(MessageOpenPgpView.java:385) E/AndroidRuntime(25655): at com.fsck.k9.view.MessageOpenPgpView.access$3(MessageOpenPgpView.java:384) E/AndroidRuntime(25655): at com.fsck.k9.view.MessageOpenPgpView$DecryptVerifyCallback.onReturn(MessageOpenPgpView.java:357) E/AndroidRuntime(25655): at org.openintents.openpgp.util.OpenPgpApi$OpenPgpAsyncTask.onPostExecute(OpenPgpApi.java:195) E/AndroidRuntime(25655): at org.openintents.openpgp.util.OpenPgpApi$OpenPgpAsyncTask.onPostExecute(OpenPgpApi.java:1) E/AndroidRuntime(25655): at android.os.AsyncTask.finish(AsyncTask.java:632) E/AndroidRuntime(25655): at android.os.AsyncTask.access$600(AsyncTask.java:177) E/AndroidRuntime(25655): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645) E/AndroidRuntime(25655): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime(25655): at android.os.Looper.loop(Looper.java:136) E/AndroidRuntime(25655): at android.app.ActivityThread.main(ActivityThread.java:5128) E/AndroidRuntime(25655): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime(25655): at java.lang.reflect.Method.invoke(Method.java:515) E/AndroidRuntime(25655): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795) E/AndroidRuntime(25655): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611) E/AndroidRuntime(25655): at dalvik.system.NativeStart.main(Native Method) --- src/com/fsck/k9/view/MessageOpenPgpView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/view/MessageOpenPgpView.java b/src/com/fsck/k9/view/MessageOpenPgpView.java index d2a00d09c..dd2cbb40b 100644 --- a/src/com/fsck/k9/view/MessageOpenPgpView.java +++ b/src/com/fsck/k9/view/MessageOpenPgpView.java @@ -381,7 +381,11 @@ public class MessageOpenPgpView extends LinearLayout { } private void handleError(final OpenPgpError error) { - mFragment.getActivity().runOnUiThread(new Runnable() { + Activity activity = mFragment.getActivity(); + if (activity == null) { + return; + } + activity.runOnUiThread(new Runnable() { @Override public void run() {