[sane-devel] a backend test

Frank Zago fzago@greshamstorage.com
Thu, 21 Mar 2002 22:28:51 -0600 (CST)


> I was getting strange results with the gphoto2 backend, and I've traced
> it to what I think is a bug in tstbackend.  Early in the program,
> sane_get_devices() is called and the result is stored in device_list[].
> Then this block is executed:
>
>         if (!devname) {
>                 if (device_list[0]) {
>                         devname = device_list[0]->name;
>                 }
>         }
>
> Then, devname is used as the device name throughout the rest of the
> program.  However, sane_exit() in dll.c frees the memory originally
> allocated by sane_get_devices, which invalidates devname.  The
> symptom I'm seeing is the value of devname getting changed, presumably
> when the memory is reallocated for some other use.   My fix is:
>
>                         devname = strdup(device_list[0]->name);

Yes, that's a bug. Thanks.

Frank.