On Thu, 10 Jul 2008, Julien BLACHE wrote:

> Brad Sawatzky <[EMAIL PROTECTED]> wrote:
> 
> > What is the intent of duplicating s->opt into s->local_opt?  If it is to
> > provide a stable local version of the scanner descriptors then shouldn't
> 
> Per the SANE standard, the descriptors have to remain available at the
> same location until the device is closed. If it wasn't the case, it'd
> be a major pain for the frontends to keep track of the options. (it
> could be done with more API calls, though, but that's added complexity
> for no benefit)
> 
> > the .constraint union (*string_list, *word_list, or *range) be duplicated
> > as well?
> 
> Nope. Whenever that changes, the backend instructs the frontend to
> reload the options. The constraints can and do change depending on
> what options you set. Also the type of constraint can change
> (resolution list vs. free resolution).

Right.  So isn't the problem that the menu is storing a pointer to a memory
that is subsequently free()'d, not the data itself?  Why is the str_list[]
array of pointers in xsane-front-gtk.c:xsane_option_menu_new() assumed to
be stable for the Source options?

The underlying bug is either:
a) The menu is being generated with its .label member pointing at memory
   that is subsequently free()'d.  That makes the memory referenced by
   menu.label subject volatile.
   - FIX: Create and store a stable version of the menu.label string.  This
     can be done either in the s->local_opt structure (which would be a pain
     to implement), or make a copy at the time the menu is created per my
     initial patch.
   - NOTE: It looks like this is exactly what is done for the resolution
     menu created by xsane_resolution_widget_new() (using strdup to make
     local copies of the resolution strings for use in menu[].label).
- OR -
b) The pointer in the menu.label for the active source menu (in this case)
   is not being kept current.
   - FIX: Recreate/update the gtk menu and do a panel_rebuild every time
     the net backend changes the NON-local opt array (since that is the
     memory referenced by the pointer stored in menu.label.

-- Brad



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to