GNOME Bugzilla – Bug 742624
[patch] Scheduled Transaction Editor results in immediate segfault
Last modified: 2018-06-29 23:37:32 UTC
Created attachment 294132 [details] fix "success" argument to gdk_colormap_alloc_colors() Looks as if this bug has been present since 2002, but I did not experience it until 2014. I start gnucash, then select Actions > Scheduled Transactions > Scheduled Transaction Editor. Gnucash immediately stops with a segmentation fault. The problem is an incorrect call to gdk_colormap_alloc_colors(GdkColormap *colormap, GdkColor *colors, gint n_colors, gboolean writeable, gboolean best_match, gboolean *success); [See https://developer.gnome.org/gdk2/stable/gdk2-Colormaps-and-Colors.html#gdk-colormap-alloc-colors] The final argument is supposed to be an array of gboolean with n_colors elements. However, in gnc-dense-cal.c'gnc_dense_cal_init(), we have: static void gnc_dense_cal_init(GncDenseCal *dcal) { gboolean colorAllocSuccess; [...] if (gdk_colormap_alloc_colors(gdk_colormap_get_system(), dcal->weekColors, MAX_COLORS, TRUE, TRUE, &colorAllocSuccess) > 0) On my system, this error caused dcal to get overwritten (gdk_colormap_alloc_colors() expected colorAllocSuccess to be bigger) and the subsequent call layout = gtk_widget_create_pango_layout(GTK_WIDGET(dcal), NULL); caused a segmentation fault because dcal was no longer valid. The attached patch changes colorAllocSuccess to an array of size MAX_COLORS.
That is a sneaky bug! Well done in discovering it and thank you for creating a patch. I have applied it to our maint branch so the fix will appear in the next version of gnucash (2.6.6).
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=742624. Please update any external references or bookmarks.