Bug 439491

Summary: SyntaxHighlighter::SyntaxHighlighter(QObject*) should NOT use a default nullptr
Product: [Frameworks and Libraries] frameworks-syntax-highlighting Reporter: RJVB <rjvbertin>
Component: frameworkAssignee: KWrite Developers <kwrite-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=439492
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 439492    

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).