Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in tiff reading method in convert.c #449

Closed
gcode-importer opened this issue Dec 10, 2014 · 3 comments
Closed

Bug in tiff reading method in convert.c #449

gcode-importer opened this issue Dec 10, 2014 · 3 comments

Comments

@gcode-importer
Copy link

Originally reported on Google Code with ID 449

In the following block of code:

if((index < imgsize)&(index+1 < imgsize))
{
 image->comps[0].data[index]   = ( dat8[i+0]<<4 )        |(dat8[i+1]>>4);
 image->comps[1].data[index]   = ((dat8[i+1]& 0x0f)<< 8) | dat8[i+2];

 image->comps[2].data[index]   = ( dat8[i+3]<<4)         |(dat8[i+4]>>4);
 image->comps[0].data[index+1] = ((dat8[i+4]& 0x0f)<< 8) | dat8[i+5];

 image->comps[1].data[index+1] = ( dat8[i+6] <<4)        |(dat8[i+7]>>4);
 image->comps[2].data[index+1] = ((dat8[i+7]& 0x0f)<< 8) | dat8[i+8];
 index += 2;
}

In first line, it should be logical and, not bitwise and.

In fact, we don't need the line (index < imgSize) at all.

Reported by boxerab on 2014-12-10 03:43:27

@gcode-importer
Copy link
Author

Aaron,

I'll only correct the logical && for now.

The other suggestion seems valid but for overflow checking (we're talking about signed
values so it might not apply given the C standard), I'll let it live like this. It
might be modified with Issue 264 anyway.

Reported by mayeut on 2014-12-11 20:01:49

  • Status changed: Started

@gcode-importer
Copy link
Author

This issue was closed by revision r2954.

Reported by mayeut on 2014-12-11 20:21:34

  • Status changed: Fixed

@gcode-importer
Copy link
Author

Hi Matthieu,

Actually, yes, you're right, you do need both conditions. In case imgSize is odd.

But, if imgSize is odd, we have another bug:  the last line will be cut off by this
method.  For 12 bit Cinema files.  

Not sure how important this is though.

I will open another issue.

Cheers,
Aaron

Reported by boxerab on 2014-12-11 23:31:56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant