Bug 463683

Summary: Null pointer access pasting from empty clipboard
Product: [Applications] konsole Reporter: Christopher Yeleighton <giecrilj>
Component: copy-pasteAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 22.12.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description Christopher Yeleighton 2023-01-01 00:26:28 UTC
SUMMARY
When the clipboard is empty (! QClipboard ::mimeData (QClipboard::Clipboard)), Konsole crashes on paste.


STEPS TO REPRODUCE
1. { konsole --platform vnc; }
2. Connect to the VNC server!
3. Tell Konsole to paste!

OBSERVED RESULT
#0  0x00007ffff6900d6b in QMimeData::hasUrls (this=this@entry=0x0)
    at ../../include/QtCore/../../src/corelib/text/qstring.h:967
967         Q_DECL_CONSTEXPR inline QString(QStringDataPtr dd) : d(dd.ptr) {}
#1  0x00007ffff7e995ff in Konsole::TerminalDisplay::pasteFromClipboard (this=0x555555973810, 
    appendEnter=<optimized out>)
    at /usr/src/debug/konsole-22.12.0/src/terminalDisplay/TerminalDisplay.cpp:2360
2360        if (!mimeData->hasUrls()) { // fast path if there are no urls

EXPECTED RESULT
The paste command should be disabled when the clipboard is empty.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: openSUSE Tumbleweed 20221230
(available in About System)
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.101.0
Qt Version: 5.15.7

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2023-01-06 17:21:42 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/801
Comment 2 Kurt Hindenburg 2023-01-09 16:29:30 UTC
Git commit a991d8d9a470b1698c0f9a7577e97c5184fd8152 by Kurt Hindenburg, on behalf of Matan Ziv-Av.
Committed on 09/01/2023 at 15:57.
Pushed by hindenburg into branch 'master'.

When pasting from clipboard, check data is non null before dereferencing

QClipboard::mimeData may return nullptr.

M  +3    -0    src/terminalDisplay/TerminalDisplay.cpp

https://invent.kde.org/utilities/konsole/commit/a991d8d9a470b1698c0f9a7577e97c5184fd8152