path: root/examples/widgets/itemviews/
diff options
authorMarc Mutz <>2021-08-04 10:17:11 +0200
committerMarc Mutz <>2021-08-05 01:46:44 +0200
commit73fabadcee71af858388fb245fccf4e96d4ead4e (patch)
tree7c159478be31d56edd907696ac36f8913ff85e26 /examples/widgets/itemviews/
parent115f828ae406d2805869fccda9269209af646a84 (diff)
QXpmHandler: fix re-entrancy bug in xpm_color_nameHEADdev
The xpm_color_name() function returned a pointer to a function-static buffer. This is infamously non-reentrant, and an actual problem, because we explicitly allow QImage operations (incl. saving to an .xpm) from non-GUI-threads. Fix by using the CSS pattern (Caller-Supplied Storage; also used in the QAnyStringView(char32_t) and QAnyStringView(QStringBuilder) ctors) to force the caller to allocate storage in its own stack frame. As a consequence, we re-gain re-entrancy, but the returned pointer is now only valid until the end of the full-expression, which necessitated simplifying one caller (sorry!). To see why said simplification is valid, observe that xpm_color_name() writes a (now-explicit) NUL into returnable[cpp] and the old code read max(cpp, 4) characters from xpm_color_name()'s result. NB: cpp can be 5, even though the code comments say otherwise! :( [ChangeLog][QtGui][QImage] Fixed a race condition when concurrently writing .xpm files. Pick-to: 6.2 6.1 5.15 5.12 Change-Id: I36d7173d53839a52f5cdf58324474c1b32c71f33 Reviewed-by: MÃ¥rten Nordheim <>
Diffstat (limited to 'examples/widgets/itemviews/')
0 files changed, 0 insertions, 0 deletions