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 2b77e779ce
("QGtk3Theme: implement appearance function to detect dark themes").

Pick-to: 6.2 6.4
Change-Id: Ieba79baf5ac34264a988fffd172650701fa54da8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Thiago Macieira 2022-11-10 11:39:14 -08:00
parent e76bcaa203
commit 28d9f05fa1

View File

@ -190,7 +190,7 @@ Qt::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 Qt::Appearance::Dark;