[FFmpeg-devel] [PATCH 6/7] avcodec/iff: Remove transient objects from the context

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Jul 12 13:27:50 EEST 2022


This avoids keeping invalid pointers in the context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/iff.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 00d0105be3..ad96bd9191 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -45,7 +45,6 @@ typedef enum {
 } mask_type;
 
 typedef struct IffContext {
-    AVFrame *frame;
     int planesize;
     uint8_t * planebuf;
     uint8_t * ham_buf;      ///< temporary buffer for planar to chunky conversation
@@ -63,7 +62,6 @@ typedef struct IffContext {
     unsigned  masking;      ///< TODO: masking method used
     int init; // 1 if buffer and palette data already initialized, 0 otherwise
     int16_t   tvdc[16];     ///< TVDC lookup table
-    GetByteContext gb;
     uint8_t *video[2];
     unsigned video_size;
     uint32_t *pal;
@@ -1529,7 +1527,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
     int buf_size           = avpkt->size;
     const uint8_t *buf_end = buf + buf_size;
     int y, plane, res;
-    GetByteContext *gb = &s->gb;
+    GetByteContext gb0, *const gb = &gb0;
     const AVPixFmtDescriptor *desc;
 
     bytestream2_init(gb, avpkt->data, avpkt->size);
@@ -1539,7 +1537,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
     if ((res = ff_get_buffer(avctx, frame, 0)) < 0)
         return res;
-    s->frame = frame;
 
     buf      += bytestream2_tell(gb);
     buf_size -= bytestream2_tell(gb);
@@ -1558,7 +1555,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
     if (s->compression <= 0xff && (avctx->codec_tag == MKTAG('A', 'N', 'I', 'M'))) {
         if (avctx->pix_fmt == AV_PIX_FMT_PAL8)
-            memcpy(s->pal, s->frame->data[1], 256 * 4);
+            memcpy(s->pal, frame->data[1], 256 * 4);
     }
 
     switch (s->compression) {
-- 
2.34.1



More information about the ffmpeg-devel mailing list