Bug in gnucash v1.4.2 (FIX)
linas@linas.org
linas@linas.org
Mon, 31 Jul 2000 11:30:18 -0500 (CDT)
It's been rumoured that Gene Stark said:
>
> Hello -
> I know that the gnucash documentation says to send bug reports
> using the form on the gnucash.org home page, but I can't find it.
> Since I spent two or three hours on finding and fixing this bug,
> I would like to contribute the fix in case it's not already in the
> development tree.
Sorry.
We had a bug tracking tool for a while, but it didn't work well & got
taken down. If you do any more patching, send them to
gnucash-patches@gnucash.org.
> DESCRIPTION
>
> I compiled gnucash v1.4.2. under FreeBSD 3.4 using the FreeBSD
> "port", using lesstif and gnomelibs. When I ran gnucash, the main
you don't need lestiff for the 1.4.x series, they're pure gnome/gtk,
there's no motif in them.
> window worked OK, but when I tried to open an account in the register
> window, essentially anything I did caused an arithmetic exception/core
> dump.
>
> It looked like the program would be really useful to me, so I
> went to the trouble of recompiling gnucash and the gnome libs with debugging
> symbols, and found out that the problem occured out of
> libgnomeui/gnome-canvas.c in the following code:
Thanks for the fix, I patched both the 1.4 and 1.5 branches with the
more conservative
INT_MAX/2 -1
>
> -----------------------------------------------------------------------
> /* If the item is visible, requests a redraw of it. */
> static void
> redraw_if_visible (GnomeCanvasItem *item)
> {
> if (item->object.flags & GNOME_CANVAS_ITEM_VISIBLE)
> gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2 + 1, item->y2 + 1);
> }
> -----------------------------------------------------------------------
>
> This was getting called with an item that had x2 and y2 set to
> INT_MAX. Adding one to these values caused an overflow and core dump.
>
> I traced the source of the problem to register/gnome/gnucash-header.c
> where the following code appears:
>
> -----------------------------------------------------------------------
> static void
> gnucash_header_update (GnomeCanvasItem *item, double *affine,
> ArtSVP *clip_path, int flags)
> {
> if (GNOME_CANVAS_ITEM_CLASS(gnucash_header_parent_class)->update)
> (*GNOME_CANVAS_ITEM_CLASS(gnucash_header_parent_class)->update)
> (item, affine, clip_path, flags);
>
> item->x1 = 0;
> item->y1 = 0;
> item->x2 = INT_MAX;
> item->y2 = INT_MAX;
> }
> -----------------------------------------------------------------------
>
>
> Similar code appears in register/gnome/gnucash-grid.c:
>
> -----------------------------------------------------------------------
> static void
> gnucash_grid_update (GnomeCanvasItem *item, double *affine,
> ArtSVP *clip_path, int flags)
> {
> if (GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->update)
> (* GNOME_CANVAS_ITEM_CLASS (gnucash_grid_parent_class)->update)
> (item, affine, clip_path, flags);
>
> item->x1 = 0;
> item->y1 = 0;
> item->x2 = INT_MAX;
> item->y2 = INT_MAX;
>
> gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent),
> item);
> }
> -----------------------------------------------------------------------
>
> By changing the occurrences of INT_MAX in the above code to INT_MAX-1,
> the problem was solved. Context diffs appear at the end of this
> message.
>
> - Gene Stark
>
>
> *** gnucash-header.c.orig Sat Jun 3 05:21:20 2000
> --- gnucash-header.c Mon Jul 31 09:08:55 2000
> ***************
> *** 53,60 ****
>
> item->x1 = 0;
> item->y1 = 0;
> ! item->x2 = INT_MAX;
> ! item->y2 = INT_MAX;
> }
>
>
> --- 53,60 ----
>
> item->x1 = 0;
> item->y1 = 0;
> ! item->x2 = INT_MAX-1;
> ! item->y2 = INT_MAX-1;
> }
>
>
>
>
>
> *** gnucash-grid.c.orig Mon Apr 24 23:28:12 2000
> --- gnucash-grid.c Mon Jul 31 09:07:49 2000
> ***************
> *** 112,119 ****
>
> item->x1 = 0;
> item->y1 = 0;
> ! item->x2 = INT_MAX;
> ! item->y2 = INT_MAX;
>
> gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent),
> item);
> --- 112,119 ----
>
> item->x1 = 0;
> item->y1 = 0;
> ! item->x2 = INT_MAX-1;
> ! item->y2 = INT_MAX-1;
>
> gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent),
> item);
>