]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix clipboard object handle leak on Android 3.1 to 11.0
authorPo Lu <luangruo@yahoo.com>
Sun, 16 Mar 2025 12:12:52 +0000 (20:12 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sun, 16 Mar 2025 16:37:17 +0000 (17:37 +0100)
* src/androidselect.c (extract_fd_offsets): Release retrieved
ParcelFileDescriptor objects on APIs 12 through 30.

(cherry picked from commit 2d5cf228186184b5af6e4e8ee8f5280f67f407bc)

src/androidselect.c

index 8d3cfac1df93fc52c4b57393675451deb57de37d..337747cbcb479d36276398bd79bb24c08cef0a67 100644 (file)
@@ -418,7 +418,10 @@ close_asset_fd (void *afd)
 }
 
 /* Return the offset, file descriptor and length of the data contained
-   in the asset file descriptor AFD, in *FD, *OFFSET, and *LENGTH.
+   in the asset file descriptor AFD, in *FD, *OFFSET, and *LENGTH.  AFD
+   will not be released if an exception is detected; it is the
+   responsibility of the caller to arrange that it be.
+
    Value is 0 upon success, 1 otherwise.  */
 
 static int
@@ -487,6 +490,9 @@ extract_fd_offsets (jobject afd, int *fd, jlong *offset, jlong *length)
       *fd = (*android_java_env)->CallIntMethod (android_java_env,
                                                java_fd,
                                                fd_class.get_fd);
+      android_exception_check_1 (java_fd);
+      ANDROID_DELETE_LOCAL_REF (java_fd);
+
       if (*fd >= 0)
        return 0;
     }