[sane-devel] Scanning Lineart/Halftone with MICROTEK Scanmak

mh crapsite@gmx.net
Mon, 27 May 2002 08:17:15 +0200


Henning Meier-Geinitz, Sonntag, 26. Mai 2002 20:00:
...
> > This also reveals a small bug in the pnm backend, which will cause the
> > frontend to hang in some rare cases.
> > See pnm.c around line 1162:
> >
> > /* Suck in as much of the file as possible, since it's already in the
> >    correct format. */
> >   len = fread (data, 1, max_length, infile);
> >
> > If fread returns 0, then *length is set to 0 and SANE_STATUS_GOOD is
> > returned.
>
> You did see the test for len == 0 and feof/ferror in the next lines of
> the code (CVS)? Shouldn't those tests be enough?

Obviously I didn't see it, I just saw xsane hanging after I set max_length to 
1. I was using version 1.0.7, and there's only a test for feof at the 
beginning of the function. 


> > We should replace this with
> >
> > {
> >   /* Suck in as much of the file as possible, since it's already in the
> >      correct format. */
> >   len = fread (data, 1, max_length, infile);
> >   if(len <= 0)
> >     return SANE_STATUS_EOF;
> > }
>
> If I understand the man page correctly, len can't be < 0.

I probably mixed it up with read(). 

bb
Michael