gtk: fix NULL pointer dereference

`gtk_window_get_default_size()` claims width/height are optional-out
arguments, but defers to `gtk_window_get_remembered_size()` which
may dereference a NULL-pointer.

Since `gtk_window_get_remembered_size()` is only called by
`gtk_window_get_default_size()`, collapse it into the latter
and perform the NULL check there.
This commit is contained in:
Andy Holmes 2023-11-13 12:05:31 -08:00
parent ce4d8cc6d9
commit f8c9b3394b
No known key found for this signature in database

View File

@ -397,10 +397,6 @@ static int gtk_window_focus (GtkWidget *widget,
static void gtk_window_move_focus (GtkWidget *widget,
GtkDirectionType dir);
static void gtk_window_get_remembered_size (GtkWindow *window,
int *width,
int *height);
static void gtk_window_real_activate_default (GtkWindow *window);
static void gtk_window_real_activate_focus (GtkWindow *window);
static void gtk_window_keys_changed (GtkWindow *window);
@ -3659,9 +3655,15 @@ gtk_window_get_default_size (GtkWindow *window,
int *width,
int *height)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
g_return_if_fail (GTK_IS_WINDOW (window));
gtk_window_get_remembered_size (window, width, height);
if (width != NULL)
*width = priv->default_width;
if (height != NULL)
*height = priv->default_height;
}
static gboolean
@ -3984,17 +3986,6 @@ gtk_window_unmap (GtkWidget *widget)
gtk_widget_unmap (child);
}
static void
gtk_window_get_remembered_size (GtkWindow *window,
int *width,
int *height)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
*width = priv->default_width;
*height = priv->default_height;
}
static void
check_scale_changed (GtkWindow *window)
{