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
5252 int zeros; /**< number of consecutive zero bytes encountered */
5353 int zeros_rem; /**< number of zero bytes remaining to output */
5454 uint8_t *rgb_planes;
55+ int rgb_planes_allocated;
5556 int rgb_stride;
5657 } LagarithContext;
5758
@@ -564,13 +565,12 @@ static int lag_decode_frame(AVCodecContext *avctx, · 506 unmodified lines
564565 offs[1] = offset_gu;
565566 offs[2] = offset_ry;
566567
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);
567571 if (!l->rgb_planes) {
568− l->rgb_stride = FFALIGN(avctx->width, 16);
569− l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * planes + 1);
570− if (!l->rgb_planes) {
571− av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
572− return AVERROR(ENOMEM);
573− }
572+ av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n");
573+ return AVERROR(ENOMEM);
574574 }
575575 for (i = 0; i < planes; i++)
576576 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