From 9b3fb66bd4568c05f4bd10bda7f6cc1d2ed6919e Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Mon, 6 Mar 2023 05:36:16 +0400 Subject: [PATCH] widget: Use the correct template in dispose_template() In derivable classes, the widget's class can be different from the one dispose_template() was called for, which can lead to failing the template != NULL check at best, undefined behavior at worst. Since we already pass the correct GType into the function, just use that instead. --- gtk/gtkwidget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Index: gtk-4.10.0/gtk/gtkwidget.c =================================================================== --- gtk-4.10.0.orig/gtk/gtkwidget.c +++ gtk-4.10.0/gtk/gtkwidget.c @@ -11180,7 +11180,8 @@ gtk_widget_dispose_template (GtkWidget * g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (g_type_name (widget_type) != NULL); - GtkWidgetTemplate *template = GTK_WIDGET_GET_CLASS (widget)->priv->template; + GObjectClass *object_class = g_type_class_peek (widget_type); + GtkWidgetTemplate *template = GTK_WIDGET_CLASS (object_class)->priv->template; g_return_if_fail (template != NULL); /* Tear down the automatic child data */