Gtk3: fix stack smashing on mismatch between bool and gboolean

Glib is written in C and predates C99 (though not really, glib 2.0 was
released in 2002), so it defines gboolean as int, a 4-byte type. C++'s
bool is a 1-byte type, so this caused a buffer overflow.

Problem introduced in 2b77e779ce43386d14bdd2d1109ee182bcd0d047
("QGtk3Theme: implement appearance function to detect dark themes").

Change-Id: Ieba79baf5ac34264a988fffd172650701fa54da8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 28d9f05fa1593b252e98965c8a4c6c4c7c2cf4a7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2022-11-10 11:39:14 -08:00 committed by Qt Cherry-pick Bot
parent 200b9d2e81
commit fe0bee6f9f

View File

@ -190,7 +190,7 @@ QPlatformTheme::Appearance QGtk3Theme::appearance() const
gtk-theme-name provides both light and dark variants. We can save a
regex check by testing this property first.
*/
const auto preferDark = gtkSetting<bool>("gtk-application-prefer-dark-theme");
const auto preferDark = gtkSetting<gboolean>("gtk-application-prefer-dark-theme");
if (preferDark)
return Appearance::Dark;