mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-11 09:20:51 +00:00
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.
This commit is contained in:
parent
48eb022deb
commit
bb2dab61a1
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user