Undefined behavior because of QStringView in widgetcolorizer.cpp
4cbff15f introduced undefined behavior, because QTextFragment::text()
returns a temporary QString
, which is destroyed at the end of the full expression, but the QStringView text
is checked for emptiness on the next line.
A simple fix is to inline the QStringView
statement in the check: if (!QStringView{fragment.text()}.trimmed().isEmpty())
. But the functionality that leads to empty and nonempty text
needs to be tested. Maybe it worked only thanks to a consequence of the undefined behavior. Perhaps the bug went unnoticed because text
was always empty? Untested or unused functionality?