[FFmpeg-cvslog] avcodec/j2kenc: Only allocate cblk.data once

Michael Niedermayer git at videolan.org
Fri Nov 24 05:05:24 EET 2017


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Fri Nov 24 03:49:55 2017 +0100| [7c191dfba76ce23e3605d2866f11d5c7ffcafd11] | committer: Michael Niedermayer

avcodec/j2kenc: Only allocate cblk.data once

Fixes: memleak
Found-by: <jamrial>

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7c191dfba76ce23e3605d2866f11d5c7ffcafd11
---

 libavcodec/j2kenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 362c7f0f49..32c7fddb74 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -938,7 +938,8 @@ static int encode_tile(Jpeg2000EncoderContext *s, Jpeg2000Tile *tile, int tileno
                                 }
                             }
                         }
-                        prec->cblk[cblkno].data = av_malloc(1 + 8192);
+                        if (!prec->cblk[cblkno].data)
+                            prec->cblk[cblkno].data = av_malloc(1 + 8192);
                         if (!prec->cblk[cblkno].data)
                             return AVERROR(ENOMEM);
                         encode_cblk(s, &t1, prec->cblk + cblkno, tile, xx1 - xx0, yy1 - yy0,



More information about the ffmpeg-cvslog mailing list