mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-13 07:22:52 +01:00
Catch an error in DecodeImageData().
When we are at end-of-stream, but haven't decoded all pixels, we should return an error. Also remove an obsolete TODO. Change-Id: I3fb1646136e706da536d537a54d1fa487a890630
This commit is contained in:
parent
ac8e5e42d1
commit
9f547450e0
@ -596,14 +596,12 @@ static int DecodeImageData(VP8LDecoder* const dec,
|
|||||||
const int length_sym = code - NUM_LITERAL_CODES;
|
const int length_sym = code - NUM_LITERAL_CODES;
|
||||||
const int length = GetCopyLength(length_sym, br);
|
const int length = GetCopyLength(length_sym, br);
|
||||||
const int dist_symbol = ReadSymbol(&htree_group->htrees_[DIST], br);
|
const int dist_symbol = ReadSymbol(&htree_group->htrees_[DIST], br);
|
||||||
// TODO(urvang): Evaluate if we should check 'dist_symbol', 'dist_code'
|
|
||||||
// and/or 'dist' to be valid.
|
|
||||||
VP8LFillBitWindow(br);
|
VP8LFillBitWindow(br);
|
||||||
dist_code = GetCopyDistance(dist_symbol, br);
|
dist_code = GetCopyDistance(dist_symbol, br);
|
||||||
dist = PlaneCodeToDistance(width, dist_code);
|
dist = PlaneCodeToDistance(width, dist_code);
|
||||||
if (src - data < dist || src_end - src < length) {
|
if (src - data < dist || src_end - src < length) {
|
||||||
ok = 0;
|
ok = 0;
|
||||||
goto Error;
|
goto End;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -636,16 +634,16 @@ static int DecodeImageData(VP8LDecoder* const dec,
|
|||||||
goto AdvanceByOne;
|
goto AdvanceByOne;
|
||||||
} else { // Not reached.
|
} else { // Not reached.
|
||||||
ok = 0;
|
ok = 0;
|
||||||
goto Error;
|
goto End;
|
||||||
}
|
}
|
||||||
ok = !br->error_;
|
ok = !br->error_;
|
||||||
if (!ok) goto Error;
|
if (!ok) goto End;
|
||||||
}
|
}
|
||||||
// Process the remaining rows corresponding to last row-block.
|
// Process the remaining rows corresponding to last row-block.
|
||||||
if (process_row) ProcessRows(dec, row);
|
if (process_row) ProcessRows(dec, row);
|
||||||
|
|
||||||
Error:
|
End:
|
||||||
if (br->error_ || !ok) {
|
if (br->error_ || !ok || (br->eos_ && src < src_end)) {
|
||||||
ok = 0;
|
ok = 0;
|
||||||
dec->status_ = (!br->eos_) ?
|
dec->status_ = (!br->eos_) ?
|
||||||
VP8_STATUS_BITSTREAM_ERROR : VP8_STATUS_SUSPENDED;
|
VP8_STATUS_BITSTREAM_ERROR : VP8_STATUS_SUSPENDED;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user