xscanimage SIGSEGVs (patch included)

=?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= (mikko@securitydynamics.com)
Sat, 21 Mar 1998 15:25:29 +0100 (CET)

Hi!

A sure way to crash sane on my machine is to start with "Show advanced
options" turned on, turn it off, open the preview window and click
"Aquire preview". This requires the backend to define some options as
"advanced," of course. The crash is deep down in GTK, when called
from gsg_set_sensitivity().

The following patch (at the end of panel_destroy()) stops this from
happening:

--- frontend/gtkglue.c.org Sat Mar 21 13:11:46 1998
+++ frontend/gtkglue.c Sat Mar 21 13:08:42 1998
@@ -829,6 +829,8 @@
elem->menu = 0;
}
}
+ memset (dialog->element, 0,
+ dialog->num_elements * sizeof (dialog->element[0]));
}

static void

Explanation: panel_rebuild() is called to rebuild the xscanimage
window. It simply calls panel_destroy() and builds the panel from
scratch with panel_build(), which skips entries that should not be
shown. This is OKfor panel_build() when called initially, as
gsg_create_dialog() clears the options array (element).
Panel_destroy() however does not, leaving assorted garbage pointers
for gsg_set_sensitivity() to crash on.

Another fix would be to add a test for:

((opt->cap & SANE_CAP_ADVANCED) && !dialog->advanced))

in gsg_set_sensitivity(), to skip the bogus option entries (as
panel_build() did), but then something else might crash for the same
reason somewhere else.

BTW: This is sane 0.71 with the snapscan backend, on FreeBSD 2.2.5 / 3.0.

Regards,
/Mikko

Mikko Tyo"la"ja"rvi________________________________mikko@securitydynamics.com
SecurityDynamics

--
Source code, list archive, and docs: http://www.mostang.com/sane/
To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com