Message ID | GV1P250MB073778D109E93799374C59518F05A@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM |
---|---|
State | Accepted |
Commit | 28817b90fc3ea9f7d3a3a8864fdb3191cb95fe76 |
Headers | show |
Series | [FFmpeg-devel,1/5] fftools/ffprobe: Fix memleak | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
Andreas Rheinhardt: > The code currently presumes that a return value of AVERROR(ENOMEM) > implies that ac3hdr could not be allocated, so it need not be freed. > Yet any avpriv_ac3_parse_header() might allocate more than the > AC3HeaderInfo internally (it doesn't currently), so simply free > it unconditionally. > > Fixes Coverity issues #1492870 and #1492868. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavformat/hls_sample_encryption.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/libavformat/hls_sample_encryption.c b/libavformat/hls_sample_encryption.c > index 089662905b..d5b4c11b66 100644 > --- a/libavformat/hls_sample_encryption.c > +++ b/libavformat/hls_sample_encryption.c > @@ -105,8 +105,7 @@ int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info) > > ret = avpriv_ac3_parse_header(&ac3hdr, info->setup_data, info->setup_data_length); > if (ret < 0) { > - if (ret != AVERROR(ENOMEM)) > - av_free(ac3hdr); > + av_free(ac3hdr); > return ret; > } > > @@ -317,8 +316,7 @@ static int get_next_ac3_eac3_sync_frame(CodecParserContext *ctx, AudioFrame *fra > > ret = avpriv_ac3_parse_header(&hdr, frame->data, ctx->buf_end - frame->data); > if (ret < 0) { > - if (ret != AVERROR(ENOMEM)) > - av_free(hdr); > + av_free(hdr); > return ret; > } > Will apply the rest of this patchset tomorrow unless there are objections. - Andreas
diff --git a/libavformat/hls_sample_encryption.c b/libavformat/hls_sample_encryption.c index 089662905b..d5b4c11b66 100644 --- a/libavformat/hls_sample_encryption.c +++ b/libavformat/hls_sample_encryption.c @@ -105,8 +105,7 @@ int ff_hls_senc_parse_audio_setup_info(AVStream *st, HLSAudioSetupInfo *info) ret = avpriv_ac3_parse_header(&ac3hdr, info->setup_data, info->setup_data_length); if (ret < 0) { - if (ret != AVERROR(ENOMEM)) - av_free(ac3hdr); + av_free(ac3hdr); return ret; } @@ -317,8 +316,7 @@ static int get_next_ac3_eac3_sync_frame(CodecParserContext *ctx, AudioFrame *fra ret = avpriv_ac3_parse_header(&hdr, frame->data, ctx->buf_end - frame->data); if (ret < 0) { - if (ret != AVERROR(ENOMEM)) - av_free(hdr); + av_free(hdr); return ret; }
The code currently presumes that a return value of AVERROR(ENOMEM) implies that ac3hdr could not be allocated, so it need not be freed. Yet any avpriv_ac3_parse_header() might allocate more than the AC3HeaderInfo internally (it doesn't currently), so simply free it unconditionally. Fixes Coverity issues #1492870 and #1492868. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavformat/hls_sample_encryption.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)