Message ID | AM7PR03MB66605CBEE0D50ADAC85CC0E68FA39@AM7PR03MB6660.eurprd03.prod.outlook.com |
---|---|
State | Accepted |
Commit | dd1975b0bbcfdd7d02808b3deac43f8f4073731d |
Headers | show |
Series | [FFmpeg-devel,01/27] avformat/astenc: Simplify writing padding | expand |
Andreas Rheinhardt: > Fixes memleaks in case the trailer is never written. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavformat/chromaprint.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c > index 399de725d3..b7a943e126 100644 > --- a/libavformat/chromaprint.c > +++ b/libavformat/chromaprint.c > @@ -47,8 +47,10 @@ typedef struct ChromaprintMuxContext { > #endif > } ChromaprintMuxContext; > > -static void cleanup(ChromaprintMuxContext *cpr) > +static void deinit(AVFormatContext *s) > { > + ChromaprintMuxContext *const cpr = s->priv_data; > + > if (cpr->ctx) { > ff_lock_avformat(); > chromaprint_free(cpr->ctx); > @@ -107,7 +109,6 @@ static int write_header(AVFormatContext *s) > > return 0; > fail: > - cleanup(cpr); > return AVERROR(EINVAL); > } > > @@ -156,7 +157,6 @@ fail: > chromaprint_dealloc(fp); > if (enc_fp) > chromaprint_dealloc(enc_fp); > - cleanup(cpr); > return ret; > } > > @@ -187,6 +187,7 @@ const AVOutputFormat ff_chromaprint_muxer = { > .write_header = write_header, > .write_packet = write_packet, > .write_trailer = write_trailer, > + .deinit = deinit, > .flags = AVFMT_NOTIMESTAMPS, > .priv_class = &chromaprint_class, > }; > Will apply the rest of this patchset tomorrow unless there are objections. - Andreas
diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c index 399de725d3..b7a943e126 100644 --- a/libavformat/chromaprint.c +++ b/libavformat/chromaprint.c @@ -47,8 +47,10 @@ typedef struct ChromaprintMuxContext { #endif } ChromaprintMuxContext; -static void cleanup(ChromaprintMuxContext *cpr) +static void deinit(AVFormatContext *s) { + ChromaprintMuxContext *const cpr = s->priv_data; + if (cpr->ctx) { ff_lock_avformat(); chromaprint_free(cpr->ctx); @@ -107,7 +109,6 @@ static int write_header(AVFormatContext *s) return 0; fail: - cleanup(cpr); return AVERROR(EINVAL); } @@ -156,7 +157,6 @@ fail: chromaprint_dealloc(fp); if (enc_fp) chromaprint_dealloc(enc_fp); - cleanup(cpr); return ret; } @@ -187,6 +187,7 @@ const AVOutputFormat ff_chromaprint_muxer = { .write_header = write_header, .write_packet = write_packet, .write_trailer = write_trailer, + .deinit = deinit, .flags = AVFMT_NOTIMESTAMPS, .priv_class = &chromaprint_class, };
Fixes memleaks in case the trailer is never written. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavformat/chromaprint.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)