[sane-devel] a backend test

Frank Zago fzago at greshamstorage.com
Fri Mar 22 04:28:51 GMT 2002


> 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.




More information about the sane-devel mailing list