Bug 439492 - TextCreator::create() crashes in QSyntaxHighligher.
Summary: TextCreator::create() crashes in QSyntaxHighligher.
Status: RESOLVED UPSTREAM
Alias: None
Product: kio-extras
Classification: Frameworks and Libraries
Component: Thumbnails and previews (show other bugs)
Version: unspecified
Platform: Compiled Sources All
: NOR crash
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on: 439491
Blocks:
  Show dependency treegraph
 
Reported: 2021-07-04 19:53 UTC by RJVB
Modified: 2021-07-04 20:39 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ;) )