Message ID | 20210319005244.1737816-3-andreas.rheinhardt@gmail.com |
---|---|
State | Accepted |
Commit | 7f985c21744520dc38084d6badd17e4d00072e49 |
Headers | show |
Series | [FFmpeg-devel,1/4] avformat/tests/fifo_muxer: Fix leak of AVPacket on error | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
On 3/18/2021 9:52 PM, Andreas Rheinhardt wrote: > Regression since 2101b99777860c853ca2321031eb3f4047dc5894. > Fixes Coverity issue #1473721. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > --- > libavcodec/libxvid.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c > index 7dc6859571..25b0025d5f 100644 > --- a/libavcodec/libxvid.c > +++ b/libavcodec/libxvid.c > @@ -692,8 +692,10 @@ FF_ENABLE_DEPRECATION_WARNINGS > return AVERROR(ENOMEM); > > picture = av_frame_alloc(); > - if (!picture) > + if (!picture) { > + av_packet_free(&packet); > return AVERROR(ENOMEM); > + } > > xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); > if( xerr ) { You could also combine both checks, like so: > diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c > index 7dc6859571..22c6025377 100644 > --- a/libavcodec/libxvid.c > +++ b/libavcodec/libxvid.c > @@ -688,12 +688,12 @@ FF_ENABLE_DEPRECATION_WARNINGS > int size, got_packet, ret; > > packet = av_packet_alloc(); > - if (!packet) > - return AVERROR(ENOMEM); > - > picture = av_frame_alloc(); > - if (!picture) > + if (!picture || !packet) { > + av_packet_free(&packet); > + av_frame_free(&picture); > return AVERROR(ENOMEM); > + } > > xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); > if( xerr ) { But it LGTM either way.
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index 7dc6859571..25b0025d5f 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -692,8 +692,10 @@ FF_ENABLE_DEPRECATION_WARNINGS return AVERROR(ENOMEM); picture = av_frame_alloc(); - if (!picture) + if (!picture) { + av_packet_free(&packet); return AVERROR(ENOMEM); + } xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); if( xerr ) {
Regression since 2101b99777860c853ca2321031eb3f4047dc5894. Fixes Coverity issue #1473721. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavcodec/libxvid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)