[tor-commits] [orbot/master] conn may be null, but service may be bound, so make sure it is unbound here

n8fr8 at torproject.org n8fr8 at torproject.org
Wed Dec 22 21:55:11 UTC 2021


commit da4162833e049c26ebb54468610d1508b398e529
Author: n8fr8 <nathan at guardianproject.info>
Date:   Tue Dec 21 12:46:37 2021 -0500

    conn may be null, but service may be bound, so make sure it is unbound here
---
 .../main/java/org/torproject/android/service/OrbotService.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
index 5fd05409..491fe1fa 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java
@@ -409,6 +409,11 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
      */
     private void stopTor() throws Exception {
 
+        if (shouldUnbindTorService) {
+            unbindService(torServiceConnection);
+            shouldUnbindTorService = false;
+        }
+
         if (conn != null) {
             logNotice("Using control port to shutdown Tor");
 
@@ -420,11 +425,6 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
                 Log.d(OrbotConstants.TAG, "error shutting down Tor via connection", e);
             }
 
-            if (shouldUnbindTorService) {
-                unbindService(torServiceConnection);
-                shouldUnbindTorService = false;
-            }
-
             conn = null;
         } else {
             stopSelf();





More information about the tor-commits mailing list