[FFmpeg-cvslog] libavformat/mov: Fix memleaks when demuxing DV audio
ffmpeg | branch: release/3.3 | Andreas Rheinhardt | Mon Sep 16 15:48:31 2019 +0200| [b6f31b41cc5260fb99f28ca0244b20e00f883559] | committer: Andreas Rheinhardt libavformat/mov: Fix memleaks when demuxing DV audio The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b6f31b41cc5260fb99f28ca0244b20e00f883559 --- libavformat/mov.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index f4687db54e..2a04b62f80 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6341,6 +6341,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } return ret; } +#if CONFIG_DV_DEMUXER +if (mov->dv_demux && sc->dv_audio_container) { +AVBufferRef *buf = pkt->buf; +ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); +pkt->buf = buf; +av_packet_unref(pkt); +if (ret < 0) +return ret; +ret = avpriv_dv_get_packet(mov->dv_demux, pkt); +if (ret < 0) +return ret; +} +#endif if (sc->has_palette) { uint8_t *pal; @@ -6352,16 +6365,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->has_palette = 0; } } -#if CONFIG_DV_DEMUXER -if (mov->dv_demux && sc->dv_audio_container) { -avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); -av_freep(>data); -pkt->size = 0; -ret = avpriv_dv_get_packet(mov->dv_demux, pkt); -if (ret < 0) -return ret; -} -#endif if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) { if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0) st->need_parsing = AVSTREAM_PARSE_FULL; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavformat/mov: Fix memleaks when demuxing DV audio
ffmpeg | branch: release/3.4 | Andreas Rheinhardt | Mon Sep 16 15:48:31 2019 +0200| [41a3aab5da52307afa3d6d28c17aae24ba7af101] | committer: Andreas Rheinhardt libavformat/mov: Fix memleaks when demuxing DV audio The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=41a3aab5da52307afa3d6d28c17aae24ba7af101 --- libavformat/mov.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ac4d3ceb29..c8033edb48 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6647,6 +6647,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } return ret; } +#if CONFIG_DV_DEMUXER +if (mov->dv_demux && sc->dv_audio_container) { +AVBufferRef *buf = pkt->buf; +ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); +pkt->buf = buf; +av_packet_unref(pkt); +if (ret < 0) +return ret; +ret = avpriv_dv_get_packet(mov->dv_demux, pkt); +if (ret < 0) +return ret; +} +#endif if (sc->has_palette) { uint8_t *pal; @@ -6658,16 +6671,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->has_palette = 0; } } -#if CONFIG_DV_DEMUXER -if (mov->dv_demux && sc->dv_audio_container) { -avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); -av_freep(>data); -pkt->size = 0; -ret = avpriv_dv_get_packet(mov->dv_demux, pkt); -if (ret < 0) -return ret; -} -#endif if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) { if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0) st->need_parsing = AVSTREAM_PARSE_FULL; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavformat/mov: Fix memleaks when demuxing DV audio
ffmpeg | branch: release/4.1 | Andreas Rheinhardt | Mon Sep 16 15:48:31 2019 +0200| [2fdd500efef80abc594dc104378c5b6a838aea4d] | committer: Andreas Rheinhardt libavformat/mov: Fix memleaks when demuxing DV audio The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2fdd500efef80abc594dc104378c5b6a838aea4d --- libavformat/mov.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 48c74eb8aa..10dd3e2378 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7750,6 +7750,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } return ret; } +#if CONFIG_DV_DEMUXER +if (mov->dv_demux && sc->dv_audio_container) { +AVBufferRef *buf = pkt->buf; +ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); +pkt->buf = buf; +av_packet_unref(pkt); +if (ret < 0) +return ret; +ret = avpriv_dv_get_packet(mov->dv_demux, pkt); +if (ret < 0) +return ret; +} +#endif if (sc->has_palette) { uint8_t *pal; @@ -7761,16 +7774,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->has_palette = 0; } } -#if CONFIG_DV_DEMUXER -if (mov->dv_demux && sc->dv_audio_container) { -avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); -av_freep(>data); -pkt->size = 0; -ret = avpriv_dv_get_packet(mov->dv_demux, pkt); -if (ret < 0) -return ret; -} -#endif if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) { if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0) st->need_parsing = AVSTREAM_PARSE_FULL; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavformat/mov: Fix memleaks when demuxing DV audio
ffmpeg | branch: release/4.2 | Andreas Rheinhardt | Mon Sep 16 15:48:31 2019 +0200| [b1d8fac858870964da27729569d650415db7dabd] | committer: Andreas Rheinhardt libavformat/mov: Fix memleaks when demuxing DV audio The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b1d8fac858870964da27729569d650415db7dabd --- libavformat/mov.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index e0a324afa4..ecaf692546 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7753,6 +7753,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } return ret; } +#if CONFIG_DV_DEMUXER +if (mov->dv_demux && sc->dv_audio_container) { +AVBufferRef *buf = pkt->buf; +ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); +pkt->buf = buf; +av_packet_unref(pkt); +if (ret < 0) +return ret; +ret = avpriv_dv_get_packet(mov->dv_demux, pkt); +if (ret < 0) +return ret; +} +#endif if (sc->has_palette) { uint8_t *pal; @@ -7764,16 +,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->has_palette = 0; } } -#if CONFIG_DV_DEMUXER -if (mov->dv_demux && sc->dv_audio_container) { -avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); -av_freep(>data); -pkt->size = 0; -ret = avpriv_dv_get_packet(mov->dv_demux, pkt); -if (ret < 0) -return ret; -} -#endif if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) { if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0) st->need_parsing = AVSTREAM_PARSE_FULL; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavformat/mov: Fix memleaks when demuxing DV audio
ffmpeg | branch: release/4.3 | Andreas Rheinhardt | Mon Sep 16 15:48:31 2019 +0200| [7c1ad9d1514a16d56cb0803787b62694fd9b6b24] | committer: Andreas Rheinhardt libavformat/mov: Fix memleaks when demuxing DV audio The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7c1ad9d1514a16d56cb0803787b62694fd9b6b24 --- libavformat/mov.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 4e68532b69..54c0fd7020 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7909,6 +7909,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } return ret; } +#if CONFIG_DV_DEMUXER +if (mov->dv_demux && sc->dv_audio_container) { +AVBufferRef *buf = pkt->buf; +ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); +pkt->buf = buf; +av_packet_unref(pkt); +if (ret < 0) +return ret; +ret = avpriv_dv_get_packet(mov->dv_demux, pkt); +if (ret < 0) +return ret; +} +#endif if (sc->has_palette) { uint8_t *pal; @@ -7920,16 +7933,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->has_palette = 0; } } -#if CONFIG_DV_DEMUXER -if (mov->dv_demux && sc->dv_audio_container) { -avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); -av_freep(>data); -pkt->size = 0; -ret = avpriv_dv_get_packet(mov->dv_demux, pkt); -if (ret < 0) -return ret; -} -#endif if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) { if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0) st->need_parsing = AVSTREAM_PARSE_FULL; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavformat/mov: Fix memleaks when demuxing DV audio
ffmpeg | branch: release/2.8 | Andreas Rheinhardt | Mon Sep 16 15:48:31 2019 +0200| [af773c60d6e5b375a6c38a135c6aacaf26481b29] | committer: Andreas Rheinhardt libavformat/mov: Fix memleaks when demuxing DV audio The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=af773c60d6e5b375a6c38a135c6aacaf26481b29 --- libavformat/mov.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 8b774ef53c..60538d4f66 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4816,6 +4816,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->current_sample -= should_retry(sc->pb, ret); return ret; } +#if CONFIG_DV_DEMUXER +if (mov->dv_demux && sc->dv_audio_container) { +AVBufferRef *buf = pkt->buf; +ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); +pkt->buf = buf; +av_packet_unref(pkt); +if (ret < 0) +return ret; +ret = avpriv_dv_get_packet(mov->dv_demux, pkt); +if (ret < 0) +return ret; +} +#endif if (sc->has_palette) { uint8_t *pal; @@ -4827,16 +4840,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->has_palette = 0; } } -#if CONFIG_DV_DEMUXER -if (mov->dv_demux && sc->dv_audio_container) { -avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); -av_freep(>data); -pkt->size = 0; -ret = avpriv_dv_get_packet(mov->dv_demux, pkt); -if (ret < 0) -return ret; -} -#endif } pkt->stream_index = sc->ffindex; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavformat/mov: Fix memleaks when demuxing DV audio
ffmpeg | branch: release/4.0 | Andreas Rheinhardt | Mon Sep 16 15:48:31 2019 +0200| [4faf2eee1c3da157f1ab67772c7a01ac231429c3] | committer: Andreas Rheinhardt libavformat/mov: Fix memleaks when demuxing DV audio The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4faf2eee1c3da157f1ab67772c7a01ac231429c3 --- libavformat/mov.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 8e46ab1bcf..40774d3911 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7147,6 +7147,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } return ret; } +#if CONFIG_DV_DEMUXER +if (mov->dv_demux && sc->dv_audio_container) { +AVBufferRef *buf = pkt->buf; +ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); +pkt->buf = buf; +av_packet_unref(pkt); +if (ret < 0) +return ret; +ret = avpriv_dv_get_packet(mov->dv_demux, pkt); +if (ret < 0) +return ret; +} +#endif if (sc->has_palette) { uint8_t *pal; @@ -7158,16 +7171,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->has_palette = 0; } } -#if CONFIG_DV_DEMUXER -if (mov->dv_demux && sc->dv_audio_container) { -avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); -av_freep(>data); -pkt->size = 0; -ret = avpriv_dv_get_packet(mov->dv_demux, pkt); -if (ret < 0) -return ret; -} -#endif if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) { if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0) st->need_parsing = AVSTREAM_PARSE_FULL; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavformat/mov: Fix memleaks when demuxing DV audio
ffmpeg | branch: release/3.2 | Andreas Rheinhardt | Mon Sep 16 15:48:31 2019 +0200| [e26c58d8e023aab157c3d1828109a4128b8b6915] | committer: Andreas Rheinhardt libavformat/mov: Fix memleaks when demuxing DV audio The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt (cherry picked from commit 61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73) Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e26c58d8e023aab157c3d1828109a4128b8b6915 --- libavformat/mov.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 929dbb4216..e01fe1a137 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -5869,6 +5869,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->current_sample -= should_retry(sc->pb, ret); return ret; } +#if CONFIG_DV_DEMUXER +if (mov->dv_demux && sc->dv_audio_container) { +AVBufferRef *buf = pkt->buf; +ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); +pkt->buf = buf; +av_packet_unref(pkt); +if (ret < 0) +return ret; +ret = avpriv_dv_get_packet(mov->dv_demux, pkt); +if (ret < 0) +return ret; +} +#endif if (sc->has_palette) { uint8_t *pal; @@ -5880,16 +5893,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->has_palette = 0; } } -#if CONFIG_DV_DEMUXER -if (mov->dv_demux && sc->dv_audio_container) { -avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); -av_freep(>data); -pkt->size = 0; -ret = avpriv_dv_get_packet(mov->dv_demux, pkt); -if (ret < 0) -return ret; -} -#endif if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) { if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0) st->need_parsing = AVSTREAM_PARSE_FULL; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] libavformat/mov: Fix memleaks when demuxing DV audio
ffmpeg | branch: master | Andreas Rheinhardt | Mon Sep 16 15:48:31 2019 +0200| [61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73] | committer: Andreas Rheinhardt libavformat/mov: Fix memleaks when demuxing DV audio The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=61f5c6ab06fc61e0f9f8f8dab5595b8bb202df73 --- libavformat/mov.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index adc52de947..8be01dd66b 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7898,6 +7898,19 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } return ret; } +#if CONFIG_DV_DEMUXER +if (mov->dv_demux && sc->dv_audio_container) { +AVBufferRef *buf = pkt->buf; +ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); +pkt->buf = buf; +av_packet_unref(pkt); +if (ret < 0) +return ret; +ret = avpriv_dv_get_packet(mov->dv_demux, pkt); +if (ret < 0) +return ret; +} +#endif if (sc->has_palette) { uint8_t *pal; @@ -7909,16 +7922,6 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) sc->has_palette = 0; } } -#if CONFIG_DV_DEMUXER -if (mov->dv_demux && sc->dv_audio_container) { -avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); -av_freep(>data); -pkt->size = 0; -ret = avpriv_dv_get_packet(mov->dv_demux, pkt); -if (ret < 0) -return ret; -} -#endif if (st->codecpar->codec_id == AV_CODEC_ID_MP3 && !st->need_parsing && pkt->size > 4) { if (ff_mpa_check_header(AV_RB32(pkt->data)) < 0) st->need_parsing = AVSTREAM_PARSE_FULL; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".