diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 286cbc2..54fafa8 100644
a
|
b
|
static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
398 | 398 | { |
399 | 399 | int c, line, pixels, code; |
400 | 400 | const uint8_t *ssrc = src; |
| 401 | uint8_t *src2 = NULL; |
401 | 402 | int width = ((s->width * s->bpp) + 7) >> 3; |
402 | 403 | |
403 | 404 | if (size <= 0) |
… |
… |
static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
449 | 450 | } |
450 | 451 | #endif |
451 | 452 | if (s->compr == TIFF_LZW) { |
| 453 | if (s->fill_order) { |
| 454 | int i; |
| 455 | src2 = av_malloc((unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE); |
| 456 | if (!src2) { |
| 457 | av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n"); |
| 458 | return AVERROR(ENOMEM); |
| 459 | } |
| 460 | for (i = 0; i < size; i++) |
| 461 | src2[i] = ff_reverse[src[i]]; |
| 462 | memset(src2 + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); |
| 463 | src = src2; |
| 464 | ssrc = src; |
| 465 | } |
452 | 466 | if (ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF) < 0) { |
453 | 467 | av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n"); |
| 468 | av_free(src2); |
454 | 469 | return -1; |
455 | 470 | } |
456 | 471 | } |
… |
… |
static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
554 | 569 | if (pixels < width) { |
555 | 570 | av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n", |
556 | 571 | pixels, width); |
| 572 | av_free(src2); |
557 | 573 | return -1; |
558 | 574 | } |
559 | 575 | if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8) |
560 | 576 | horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0); |
| 577 | av_free(src2); |
561 | 578 | break; |
562 | 579 | } |
563 | 580 | dst += stride; |