qiqian / webp

Automatically exported from code.google.com/p/webp
0 stars 0 forks source link

WebPINew* wrong without buffer #139

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When in src/dec/idec.c WebPINewRGB or WebPINewYUVA are fed with a NULL buffer, 
the internal memory is not used correctly.

Reason: 
idec->output_.is_external_memory is always set to 1 (true) instead of testing 
the given buffer pointer for NULL.

Remedy:
In WebPINewRGB:
Replace: idec->output_.is_external_memory = 1;
by: idec->output_.is_external_memory = (output_buffer!=NULL);

In WebPINewYUVA:
Replace: idec->output_.is_external_memory = 1;
by: idec->output_.is_external_memory = (luma!=NULL);

Original issue reported on code.google.com by _-jan...@web.de on 25 Jan 2013 at 9:14

GoogleCodeExporter commented 8 years ago
Hi,

thanks for the report.
Actually, silently forcing is_external_memory to false when output_buffer is 
incorrect might be a surprising behaviour from caller's standpoint.

I think best is to report an error (INVALID_PARAM) when output_buffer is NULL 
(or when output_buffer_size is suspicious, too). No?

Original comment by pascal.m...@gmail.com on 25 Jan 2013 at 10:01

GoogleCodeExporter commented 8 years ago
for definiteness, here's the likely fix: 
https://gerrit.chromium.org/gerrit/42003

Original comment by pascal.m...@gmail.com on 25 Jan 2013 at 10:05

GoogleCodeExporter commented 8 years ago
Once more:

While porting an old reader from 0.1.2 to 0.2.1 I had to replace WebPINew with 
WebPINewRGB and I wondered why I now need a buffer.
The code was taken from the sample in decode.h ("Incremental decoding").
When I provided a buffer smaller than the image file the decoding gave me an 
error (invalid parameter) after feeding some parts of the file. I might have 
overlooked a necessary buffer initialization.
Without a buffer I too got this error.
However when by looking at the sources I noticed that the field 
is_external_memory was unconditionally set to 1. Changing that as described 
fixed all my problems and I even got rid of the extra buffer.

Original comment by _-jan...@web.de on 25 Jan 2013 at 10:28

GoogleCodeExporter commented 8 years ago
Hi,

i see, it make sense.
I've uploaded a new patch at https://gerrit.chromium.org/gerrit/#/c/42003/3
Would that work in your case?

Original comment by pascal.m...@gmail.com on 25 Jan 2013 at 3:30

GoogleCodeExporter commented 8 years ago
It seems to work for me.
Thank you very much.

Original comment by _-jan...@web.de on 28 Jan 2013 at 7:26

GoogleCodeExporter commented 8 years ago
great! submitted the patch.
Thanks for the report and suggestion.

Original comment by pascal.m...@gmail.com on 28 Jan 2013 at 12:06