diff mbox series

[FFmpeg-devel,18/30] avcodec/ljpegenc: Don't free buffer known to be NULL

Message ID 20200915074000.102622-18-andreas.rheinhardt@gmail.com
State Accepted
Commit 6015a6921eba7b01b1e23ebd46f0f9f14b6c6f7b
Headers show
Series [FFmpeg-devel,01/30] avcodec/flashsvenc: Avoid allocation of buffer, fix memleak | expand


Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 15, 2020, 7:39 a.m. UTC
The lossless JPEG encoder allocates one buffer in its init function
and freeing said buffer is the only thing done in its close function.
Despite this the init function called the close function if allocating
said buffer fails, although there is nothing to free in this case.
This commit stops doing this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
 libavcodec/ljpegenc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
diff mbox series


diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 70eff9e6fe..39ce5a0089 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
     s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch));
     if (!s->scratch)
-        goto fail;
+        return AVERROR(ENOMEM);
     ff_idctdsp_init(&s->idsp, avctx);
     ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
     return 0;
-    ljpeg_encode_close(avctx);
-    return AVERROR(ENOMEM);
 #define OFFSET(x) offsetof(LJpegEncContext, x)