History

lagarith: reallocate rgb_planes when needed

Fixes invalid writes on pixel format changes.

Anton Khirnov committed 12 years ago

Commit 4c3e1951 parent 2240e201 file · +6 −6Browse files

Unified · Split

libavcodec/lagarith.c+6−6
@@ -52,6 +52,7 @@ typedef struct LagarithContext { · 51 unmodified lines
52 int zeros; /**< number of consecutive zero bytes encountered */52 int zeros; /**< number of consecutive zero bytes encountered */
53 int zeros_rem; /**< number of zero bytes remaining to output */53 int zeros_rem; /**< number of zero bytes remaining to output */
54 uint8_t *rgb_planes;54 uint8_t *rgb_planes;
55 int rgb_planes_allocated;
55 int rgb_stride;56 int rgb_stride;
56} LagarithContext;57} LagarithContext;
57 58
@@ -564,13 +565,12 @@ static int lag_decode_frame(AVCodecContext *avctx, · 506 unmodified lines
564 offs[1] = offset_gu;565 offs[1] = offset_gu;
565 offs[2] = offset_ry;566 offs[2] = offset_ry;
566 567
568 l->rgb_stride = FFALIGN(avctx->width, 16);
569 av_fast_malloc(&l->rgb_planes, &l->rgb_planes_allocated,
570 l->rgb_stride * avctx->height * planes + 1);
567 if (!l->rgb_planes) {571 if (!l->rgb_planes) {
568 l->rgb_stride = FFALIGN(avctx->width, 16);572 av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
569 l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * planes + 1);573 return AVERROR(ENOMEM);
570 if (!l->rgb_planes) {
571 av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
572 return AVERROR(ENOMEM);
573 }
574 }574 }
575 for (i = 0; i < planes; i++)575 for (i = 0; i < planes; i++)
576 srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride;576 srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t