Bug 439492

Summary: TextCreator::create() crashes in QSyntaxHighligher.
Product: [Frameworks and Libraries] kio-extras Reporter: RJVB <rjvbertin>
Component: Thumbnails and previewsAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: crash CC: christoph
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: All   
See Also: https://bugs.kde.org/show_bug.cgi?id=439491
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on: 439491    
Bug Blocks:    

Description RJVB 2021-07-04 19:53:33 UTC
SUMMARY
TextCreator::create() creates a locate instance using `KSyntaxHighlighting::SyntaxHighlighter syntaxHighlighter;` which leads to a nullptr dereference in `QSyntaxHighlighter::QSyntaxHighlighter(QObject*)`.

STEPS TO REPRODUCE
1. Open a directory in Dolphin, activate hover-on previews
2. Hover the cursor over a .txt file

OBSERVED RESULT
kdeinit5 crashes because of the nullptr dereference.

EXPECTED RESULT
No crash.

SOFTWARE/OS VERSIONS
Happens on Mac & Linux; as far as I can tell this should happen with the current Qt5 release and the most recent versions of kio-extras and KSyntaxHighlighting.

ADDITIONAL INFORMATION
The function should call `KSyntaxHighlighting::SyntaxHighlighter syntaxHighlighter(&textDocument);` which makes the later call to `setDocument()` unnecessary.
Comment 1 Christoph Cullmann 2021-07-04 19:55:13 UTC
Hmm, all At versions we support should have the null check, we submitted that ourselves

https://code.qt.io/cgit/qt/qtbase.git/commit/src/gui/text/qsyntaxhighlighter.cpp?id=16cb578a8d102f1c937dcc3a07b88b24c9ed685a
Comment 2 RJVB 2021-07-04 20:39:50 UTC
(You could have "unprivatised" the argument-less ctor or added a default null value in the fix ;) )