]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid crashes in some edge cases
authorPo Lu <luangruo@yahoo.com>
Thu, 27 Jul 2023 12:32:16 +0000 (20:32 +0800)
committerPo Lu <luangruo@yahoo.com>
Thu, 27 Jul 2023 12:32:16 +0000 (20:32 +0800)
* java/org/gnu/emacs/EmacsActivity.java (onActivityResult):
Avoid crashes in some edge cases.

java/org/gnu/emacs/EmacsActivity.java

index 86fed5396d7208daee12a95595ce4423763f3a53..4ddf51fbb2093d9e69ddaec7e8214b11073cb264 100644 (file)
@@ -462,8 +462,17 @@ public class EmacsActivity extends Activity
            flags = (Intent.FLAG_GRANT_READ_URI_PERMISSION
                     | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
 
-           if (uri != null)
-             resolver.takePersistableUriPermission (uri, flags);
+           try
+             {
+               if (uri != null)
+                 resolver.takePersistableUriPermission (uri, flags);
+             }
+           catch (Exception exception)
+             {
+               /* Permission to access URI might've been revoked in
+                  between selecting the file and this callback being
+                  invoked.  Don't crash in such cases.  */
+             }
          }
 
        break;