[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bb2dab61a18: Take precautions against NULL returns from getPrimar
From: |
Po Lu |
Subject: |
master bb2dab61a18: Take precautions against NULL returns from getPrimaryClip |
Date: |
Tue, 22 Aug 2023 03:29:43 -0400 (EDT) |
branch: master
commit bb2dab61a18c736ebf4cdf36be0f4796bd01f429
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
java/org/gnu/emacs/EmacsSdk11Clipboard.java | 16 +++++-----------
1 file 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)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master bb2dab61a18: Take precautions against NULL returns from getPrimaryClip,
Po Lu <=