Bug 439491 - SyntaxHighlighter::SyntaxHighlighter(QObject*) should NOT use a default nullptr
Summary: SyntaxHighlighter::SyntaxHighlighter(QObject*) should NOT use a default nullptr
Status: RESOLVED UPSTREAM
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: framework (show other bugs)
Version: unspecified
Platform: Compiled Sources All
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks: 439492
  Show dependency treegraph
 
Reported: 2021-07-04 19:45 UTC by RJVB
Modified: 2021-07-04 20:34 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:45:25 UTC
SUMMARY
SyntaxHighlighter::SyntaxHighlighter(QObject*) hands off its argument to QSyntaxHighlighter; this function does NOT check if the parent it receives that way is a valid pointer. Code should thus be obliged to pass a parent pointer explicitly - QSyntaxHighlighter does this too (no default value).

STEPS TO REPRODUCE
1. Create a KSyntaxHighlighting instance by, for instance, `KSyntaxHighlighting::SyntaxHighlighter syntaxHighlighter;`

OBSERVED RESULT
A crash will result in QSyntaxHighlighter::QSyntaxHighligher().

EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Christoph Cullmann 2021-07-04 19:54:07 UTC
I think it does in all Qt versions we atm support with frameworks:

https://code.qt.io/cgit/qt/qtbase.git/commit/src/gui/text/qsyntaxhighlighter.cpp?id=16cb578a8d102f1c937dcc3a07b88b24c9ed685a
Comment 2 Christoph Cullmann 2021-07-04 20:10:16 UTC
That patch seems to be in since Qt 5.12, given we require ATM Qt 5.15 I see no reason to alter the API now.
Comment 3 RJVB 2021-07-04 20:34:21 UTC
my bad, I must have looked at the sources of an older Qt version (and didn't see any change in Qt's API documentation).