summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-08-22 15:28:38 +0800
committerPo Lu <luangruo@yahoo.com>2023-08-22 15:28:38 +0800
commitbb2dab61a18c736ebf4cdf36be0f4796bd01f429 (patch)
tree795a571c1558823c4f8e5c10433361ad5dbbc47c
parent48eb022debb85ec3b844e6833194bb05d35cb5c5 (diff)
downloademacs-bb2dab61a18c736ebf4cdf36be0f4796bd01f429.tar.gz
Take precautions against NULL returns from getPrimaryClip
* java/org/gnu/emacs/EmacsSdk11Clipboard.java (getClipboardData): Return null if the clip data is not set. Also delete superfluous debugging code. (bug#65445) (getClipboard): Don't dereference NULL clip data.
-rw-r--r--java/org/gnu/emacs/EmacsSdk11Clipboard.java16
1 files changed, 5 insertions, 11 deletions
diff --git a/java/org/gnu/emacs/EmacsSdk11Clipboard.java b/java/org/gnu/emacs/EmacsSdk11Clipboard.java
index 4959ec36eed..b34753922b8 100644
--- a/java/org/gnu/emacs/EmacsSdk11Clipboard.java
+++ b/java/org/gnu/emacs/EmacsSdk11Clipboard.java
@@ -71,10 +71,6 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard
public synchronized void
onPrimaryClipChanged ()
{
- Log.d (TAG, ("onPrimaryClipChanged: "
- + monitoredClipboardChangedCount
- + " " + clipboardChangedCount));
-
/* Increment monitoredClipboardChangeCount. If it is now greater
than clipboardChangedCount, then Emacs no longer owns the
clipboard. */
@@ -187,6 +183,10 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard
/* N.B. that Android calls the clipboard the ``primary clip''; it
is not related to the X primary selection. */
clip = manager.getPrimaryClip ();
+
+ if (clip == null)
+ return null;
+
description = clip.getDescription ();
i = description.getMimeTypeCount ();
typeArray = new byte[i][i];
@@ -237,14 +237,12 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard
return null;
}
- Log.d (TAG, "getClipboardData: "+ mimeType);
-
/* Now obtain the clipboard data and the data corresponding to
that MIME type. */
data = manager.getPrimaryClip ();
- if (data.getItemCount () < 1)
+ if (data == null || data.getItemCount () < 1)
return null;
try
@@ -254,8 +252,6 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard
if (uri == null)
return null;
- Log.d (TAG, "getClipboardData: "+ uri);
-
/* Now open the file descriptor. */
assetFd = resolver.openTypedAssetFileDescriptor (uri, mimeType,
null);
@@ -270,8 +266,6 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard
/* Close the original offset. */
assetFd.close ();
-
- Log.d (TAG, "getClipboardData: "+ value);
}
catch (FileNotFoundException e)
{