gtksettings: Avoid a possible NULL pointer dereference

_gtk_settings_get_style_cascade() checks for the given GtkSettings to be
non-NULL, but does so after using the pointer to get the
GtkSettingsPrivate.

Make sure we use the GtkSettings pointer only after the precondition is
verified.

https://gitlab.gnome.org/GNOME/gtk/-/issues/2780
This commit is contained in:
Olivier Fourdan 2020-09-30 15:08:31 +02:00
parent cec7ff1ba7
commit 33059211f4

View File

@ -1843,12 +1843,13 @@ GtkStyleCascade *
_gtk_settings_get_style_cascade (GtkSettings *settings,
gint scale)
{
GtkSettingsPrivate *priv = settings->priv;
GtkSettingsPrivate *priv;
GtkStyleCascade *new_cascade;
GSList *list;
g_return_val_if_fail (GTK_IS_SETTINGS (settings), NULL);
priv = settings->priv;
for (list = priv->style_cascades; list; list = list->next)
{
if (_gtk_style_cascade_get_scale (list->data) == scale)