This seems to point at a regression in Gtk.

>From what I understand GTK_IS_WIDGET should return FALSE if widget is NULL.

It's defined here:
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtkwidget.h?
ref_type=heads#L46

It's a macro that calls G_TYPE_CHECK_INSTANCE_TYPE, which is defined here:
https://gitlab.gnome.org/GNOME/glib/-/blob/main/gobject/gtype.h?
ref_type=heads#L541

The comment above this definition states G_TYPE_CHECK_INSTANCE_TYPE should 
return FALSE if instance is NULL.

So I'm rather surprised this use of GTK_IS_WIDGET crashes gnucash.

Regards,

Geert

Op donderdag 2 november 2023 04:15:31 CET schreef John Ralls:
> Updated        via  https://github.com/Gnucash/gnucash/commit/5e06c8d8 
> (commit)
>       from  https://github.com/Gnucash/gnucash/commit/d617129d (commit)
> 
> 
> 
> commit 5e06c8d8a00935eff5908d71da46f148d6f01e43
> Author: John Ralls <jra...@ceridwen.us>
> Date:   Wed Nov 1 19:54:54 2023 -0700
> 
>     Fix NULL dereference in gnc_plugin_page_report_focus_widget.
> 
>     Reported by Michael Hendry in gnucash-user.
> 
> diff --git a/gnucash/gnome/gnc-plugin-page-report.cpp
> b/gnucash/gnome/gnc-plugin-page-report.cpp index 724008b4d8..a8a58ce7e0
> 100644
> --- a/gnucash/gnome/gnc-plugin-page-report.cpp
> +++ b/gnucash/gnome/gnc-plugin-page-report.cpp
> @@ -334,7 +334,7 @@ gnc_plugin_page_report_focus_widget (GncPluginPage
> *report_plugin_page) if (!priv->loaded) // so we only do the load once
>                  gnc_plugin_page_report_load_uri (report_plugin_page);
> 
> -            if (GTK_IS_WIDGET(widget))
> +            if (widget && GTK_IS_WIDGET(widget))
>              {
>                  if (!gtk_widget_is_focus (GTK_WIDGET(widget)))
>                      gtk_widget_grab_focus (GTK_WIDGET(widget));
> 
> 
> 
> Summary of changes:
>  gnucash/gnome/gnc-plugin-page-report.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> _______________________________________________
> gnucash-changes mailing list
> gnucash-chan...@gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-changes




_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to