[sane-devel] a backend test

Peter Fales psfales at lucent.com
Fri Mar 22 04:09:34 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);


--
Peter Fales

On Sun, Mar 17, 2002 at 10:09:13PM -0600, Frank Zago wrote:
> 
> New version available.
> 
> - more tests
> - displays warnings and errors instead of coredumping
> - fixes
> 
> http://fz.eryx.net/sane/#testsuite
> 
> 
> _______________________________________________
> Sane-devel mailing list
> Sane-devel at www.mostang.com
> http://www.mostang.com/mailman/listinfo/sane-devel



More information about the sane-devel mailing list