gnucash maint: Bug 797389 - Random Crashes while attaching a document.
John Ralls
jralls at code.gnucash.org
Tue Sep 3 19:20:39 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/78d4d60b (commit)
from https://github.com/Gnucash/gnucash/commit/49507484 (commit)
commit 78d4d60b9c13f4d2c2df934ad32502c203263aa3
Author: John Ralls <jralls at ceridwen.us>
Date: Tue Sep 3 16:11:27 2019 -0700
Bug 797389 - Random Crashes while attaching a document.
Fixes the immediate cause, dereferencing the return value of
gnucash_style_get_cell_dimensions, which can be NULL, without
checking.
diff --git a/gnucash/register/register-gnome/gnucash-header.c b/gnucash/register/register-gnome/gnucash-header.c
index bf2f600f5..1b2de66d7 100644
--- a/gnucash/register/register-gnome/gnucash-header.c
+++ b/gnucash/register/register-gnome/gnucash-header.c
@@ -133,6 +133,8 @@ gnc_header_draw_offscreen (GncHeader *header)
virt_loc.phys_col_offset = j;
cd = gnucash_style_get_cell_dimensions (style, i, j);
+ if (!cd) continue;
+
height = cd->pixel_height;
if (header->in_resize && (j == header->resize_col))
width = header->resize_col_width;
@@ -320,6 +322,8 @@ pointer_on_resize_line (GncHeader *header, int x, G_GNUC_UNUSED int y, int *col)
for (j = 0; j < style->ncols; j++)
{
cd = gnucash_style_get_cell_dimensions (style, 0, j);
+ if (!cd) continue;
+
pixels += cd->pixel_width;
if (x >= pixels - 1 && x <= pixels + 1)
on_the_line = TRUE;
@@ -449,6 +453,7 @@ gnc_header_event (GtkWidget *widget, GdkEvent *event)
cd = gnucash_style_get_cell_dimensions
(header->style, 0, col);
+ if (!cd) break;
header->in_resize = TRUE;
header->resize_col = col;
diff --git a/gnucash/register/register-gnome/gnucash-sheet-private.c b/gnucash/register/register-gnome/gnucash-sheet-private.c
index 808c2a2f6..92769ce61 100644
--- a/gnucash/register/register-gnome/gnucash-sheet-private.c
+++ b/gnucash/register/register-gnome/gnucash-sheet-private.c
@@ -136,7 +136,7 @@ find_cell_by_pixel (GnucashSheet *sheet, gint x, gint y,
{
cd = gnucash_style_get_cell_dimensions (style, row, 0);
- if (y >= cd->origin_y && y < cd->origin_y + cd->pixel_height)
+ if (cd && y >= cd->origin_y && y < cd->origin_y + cd->pixel_height)
break;
row++;
@@ -150,7 +150,7 @@ find_cell_by_pixel (GnucashSheet *sheet, gint x, gint y,
{
cd = gnucash_style_get_cell_dimensions (style, row, col);
- if (x >= cd->origin_x && x < cd->origin_x + cd->pixel_width)
+ if (cd && x >= cd->origin_x && x < cd->origin_x + cd->pixel_width)
break;
col++;
@@ -573,6 +573,8 @@ draw_block (GnucashSheet *sheet,
virt_loc.phys_row_offset,
virt_loc.phys_col_offset);
+ if (!cd) break;
+
x_paint = block->origin_x + cd->origin_x - x;
if (x_paint > width)
break;
diff --git a/gnucash/register/register-gnome/gnucash-style.c b/gnucash/register/register-gnome/gnucash-style.c
index 37fa3f0af..83ce8e4e8 100644
--- a/gnucash/register/register-gnome/gnucash-style.c
+++ b/gnucash/register/register-gnome/gnucash-style.c
@@ -561,6 +561,7 @@ gnucash_sheet_set_col_width (GnucashSheet *sheet, int col, int width)
g_return_if_fail (col < style->ncols);
cd = gnucash_style_get_cell_dimensions (style, 0, col);
+ if (!cd) return;
/* adjust the overall width of this style */
diff = cd->pixel_width - width;
@@ -731,6 +732,7 @@ gnucash_sheet_style_get_cell_pixel_rel_coords (SheetBlockStyle *style,
g_return_if_fail (cell_col >= 0 && cell_col <= style->ncols);
cd = gnucash_style_get_cell_dimensions (style, cell_row, cell_col);
+ if (!cd) return;
*x = cd->origin_x;
*y = cd->origin_y;
@@ -954,7 +956,7 @@ gnucash_sheet_set_header_widths (GnucashSheet *sheet,
row, col);
cell = gnc_cellblock_get_cell (header, row, col);
- if (!cell || !cell->cell_name)
+ if (!cell || !cell->cell_name || !cd)
continue;
cd->pixel_width = gnc_header_widths_get_width
Summary of changes:
gnucash/register/register-gnome/gnucash-header.c | 5 +++++
gnucash/register/register-gnome/gnucash-sheet-private.c | 6 ++++--
gnucash/register/register-gnome/gnucash-style.c | 4 +++-
3 files changed, 12 insertions(+), 3 deletions(-)
More information about the gnucash-changes
mailing list