summaryrefslogtreecommitdiffhomepage
path: root/app/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-01-10 00:54:59 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-01-10 00:54:59 +0100
commita42892bc289ac5d4b7e7ffe79001d3305172f2ea (patch)
tree12debbf3755bdec7ada5d935b5e3deb19c6b3379 /app/src
parent138ba5c416d786d24f25508cd28f946b4a27e4b5 (diff)
TunnelEditorFragment: do not pass null localConfig
Otherwise we might dereference it, per this play store gathered trace: Xiaomi Redmi 3S (land), 2048MB RAM, Android 7.1 java.lang.NullPointerException: at com.wireguard.android.model.Tunnel.setConfig (Tunnel.java:118) at com.wireguard.android.fragment.TunnelEditorFragment.onOptionsItemSelected (TunnelEditorFragment.java:160) at android.app.Fragment.performOptionsItemSelected (Fragment.java:2478) at android.app.FragmentManagerImpl.dispatchOptionsItemSelected (FragmentManager.java:2182) at android.app.FragmentController.dispatchOptionsItemSelected (FragmentController.java:336) at android.app.Activity.onMenuItemSelected (Activity.java:3211) at com.android.internal.policy.PhoneWindow.onMenuItemSelected (PhoneWindow.java:1219) at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected (MenuBuilder.java:761) at com.android.internal.view.menu.MenuItemImpl.invoke (MenuItemImpl.java:152) at com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:904) at com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:894) at android.widget.ActionMenuView.invokeItem (ActionMenuView.java:616) at com.android.internal.view.menu.ActionMenuItemView.onClick (ActionMenuItemView.java:152) at android.view.View.performClick (View.java:5637) at android.view.View$PerformClick.run (View.java:22433) at android.os.Handler.handleCallback (Handler.java:751) at android.os.Handler.dispatchMessage (Handler.java:95) at android.os.Looper.loop (Looper.java:153) at android.app.ActivityThread.main (ActivityThread.java:6244) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:891) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:781) Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
index eec5c098..aa4321e8 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
@@ -146,18 +146,19 @@ public class TunnelEditorFragment extends BaseFragment {
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_action_save:
- if (getSelectedTunnel() == null) {
+ final Tunnel selectedTunnel = getSelectedTunnel();
+ if (selectedTunnel == null) {
Log.d(TAG, "Attempting to create new tunnel " + localName.get());
final TunnelManager manager = Application.getComponent().getTunnelManager();
manager.create(localName.get(), localConfig)
.whenComplete(this::onTunnelCreated);
- } else if (!getSelectedTunnel().getName().equals(localName.get())) {
+ } else if (!selectedTunnel.getName().equals(localName.get())) {
Log.d(TAG, "Attempting to rename tunnel to " + localName.get());
- getSelectedTunnel().rename(localName.get())
+ selectedTunnel.rename(localName.get())
.whenComplete(this::onTunnelRenamed);
- } else {
- Log.d(TAG, "Attempting to save config of " + getSelectedTunnel().getName());
- getSelectedTunnel().setConfig(localConfig)
+ } else if (localConfig != null) {
+ Log.d(TAG, "Attempting to save config of " + selectedTunnel.getName());
+ selectedTunnel.setConfig(localConfig)
.whenComplete(this::onConfigSaved);
}
return true;