diff options
| author | Po Lu | 2023-08-22 15:28:38 +0800 |
|---|---|---|
| committer | Po Lu | 2023-08-22 15:28:38 +0800 |
| commit | bb2dab61a18c736ebf4cdf36be0f4796bd01f429 (patch) | |
| tree | 795a571c1558823c4f8e5c10433361ad5dbbc47c /java | |
| parent | 48eb022debb85ec3b844e6833194bb05d35cb5c5 (diff) | |
| download | emacs-bb2dab61a18c736ebf4cdf36be0f4796bd01f429.tar.gz emacs-bb2dab61a18c736ebf4cdf36be0f4796bd01f429.zip | |
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.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsSdk11Clipboard.java | 16 |
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 | |||
| 71 | public synchronized void | 71 | public synchronized void |
| 72 | onPrimaryClipChanged () | 72 | onPrimaryClipChanged () |
| 73 | { | 73 | { |
| 74 | Log.d (TAG, ("onPrimaryClipChanged: " | ||
| 75 | + monitoredClipboardChangedCount | ||
| 76 | + " " + clipboardChangedCount)); | ||
| 77 | |||
| 78 | /* Increment monitoredClipboardChangeCount. If it is now greater | 74 | /* Increment monitoredClipboardChangeCount. If it is now greater |
| 79 | than clipboardChangedCount, then Emacs no longer owns the | 75 | than clipboardChangedCount, then Emacs no longer owns the |
| 80 | clipboard. */ | 76 | clipboard. */ |
| @@ -187,6 +183,10 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard | |||
| 187 | /* N.B. that Android calls the clipboard the ``primary clip''; it | 183 | /* N.B. that Android calls the clipboard the ``primary clip''; it |
| 188 | is not related to the X primary selection. */ | 184 | is not related to the X primary selection. */ |
| 189 | clip = manager.getPrimaryClip (); | 185 | clip = manager.getPrimaryClip (); |
| 186 | |||
| 187 | if (clip == null) | ||
| 188 | return null; | ||
| 189 | |||
| 190 | description = clip.getDescription (); | 190 | description = clip.getDescription (); |
| 191 | i = description.getMimeTypeCount (); | 191 | i = description.getMimeTypeCount (); |
| 192 | typeArray = new byte[i][i]; | 192 | typeArray = new byte[i][i]; |
| @@ -237,14 +237,12 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard | |||
| 237 | return null; | 237 | return null; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | Log.d (TAG, "getClipboardData: "+ mimeType); | ||
| 241 | |||
| 242 | /* Now obtain the clipboard data and the data corresponding to | 240 | /* Now obtain the clipboard data and the data corresponding to |
| 243 | that MIME type. */ | 241 | that MIME type. */ |
| 244 | 242 | ||
| 245 | data = manager.getPrimaryClip (); | 243 | data = manager.getPrimaryClip (); |
| 246 | 244 | ||
| 247 | if (data.getItemCount () < 1) | 245 | if (data == null || data.getItemCount () < 1) |
| 248 | return null; | 246 | return null; |
| 249 | 247 | ||
| 250 | try | 248 | try |
| @@ -254,8 +252,6 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard | |||
| 254 | if (uri == null) | 252 | if (uri == null) |
| 255 | return null; | 253 | return null; |
| 256 | 254 | ||
| 257 | Log.d (TAG, "getClipboardData: "+ uri); | ||
| 258 | |||
| 259 | /* Now open the file descriptor. */ | 255 | /* Now open the file descriptor. */ |
| 260 | assetFd = resolver.openTypedAssetFileDescriptor (uri, mimeType, | 256 | assetFd = resolver.openTypedAssetFileDescriptor (uri, mimeType, |
| 261 | null); | 257 | null); |
| @@ -270,8 +266,6 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard | |||
| 270 | 266 | ||
| 271 | /* Close the original offset. */ | 267 | /* Close the original offset. */ |
| 272 | assetFd.close (); | 268 | assetFd.close (); |
| 273 | |||
| 274 | Log.d (TAG, "getClipboardData: "+ value); | ||
| 275 | } | 269 | } |
| 276 | catch (FileNotFoundException e) | 270 | catch (FileNotFoundException e) |
| 277 | { | 271 | { |