Message ID | 1568115568-14548-4-git-send-email-mypopydev@gmail.com |
---|---|
State | New |
Headers | show |
Jun Zhao: > From: Jun Zhao <barryjzhao@tencent.com> > > remove unnecessary packet reset in av_interleaved_write_frame > > Signed-off-by: Jun Zhao <barryjzhao@tencent.com> > --- > libavformat/mux.c | 6 ++---- > 1 files changed, 2 insertions(+), 4 deletions(-) > > diff --git a/libavformat/mux.c b/libavformat/mux.c > index 0227c0d..9bac252 100644 > --- a/libavformat/mux.c > +++ b/libavformat/mux.c > @@ -1227,11 +1227,9 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt) > for (;; ) { > AVPacket opkt; > int ret = interleave_packet(s, &opkt, pkt, flush); > - if (pkt) { > - memset(pkt, 0, sizeof(*pkt)); > - av_init_packet(pkt); > + if (pkt) > pkt = NULL; > - } > + > if (ret <= 0) //FIXME cleanup needed for ret<0 ? > return ret; > I made a patchset [1] (that has already been partially pushed) whose patch 11 deals with the memleak that happens on error in the above code and also removes the unnecessary packet reset on success. - Andreas [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248140.html [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248145.html
On Tue, Sep 10, 2019 at 8:05 PM Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote: > > Jun Zhao: > > From: Jun Zhao <barryjzhao@tencent.com> > > > > remove unnecessary packet reset in av_interleaved_write_frame > > > > Signed-off-by: Jun Zhao <barryjzhao@tencent.com> > > --- > > libavformat/mux.c | 6 ++---- > > 1 files changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/libavformat/mux.c b/libavformat/mux.c > > index 0227c0d..9bac252 100644 > > --- a/libavformat/mux.c > > +++ b/libavformat/mux.c > > @@ -1227,11 +1227,9 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt) > > for (;; ) { > > AVPacket opkt; > > int ret = interleave_packet(s, &opkt, pkt, flush); > > - if (pkt) { > > - memset(pkt, 0, sizeof(*pkt)); > > - av_init_packet(pkt); > > + if (pkt) > > pkt = NULL; > > - } > > + > > if (ret <= 0) //FIXME cleanup needed for ret<0 ? > > return ret; > > > I made a patchset [1] (that has already been partially pushed) whose > patch 11 deals with the memleak that happens on error in the above > code and also removes the unnecessary packet reset on success. > > - Andreas > > [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248140.html > [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248145.html > I didn't notice that pathset details, please goto the patchset, will drop the patch, Thanks
diff --git a/libavformat/mux.c b/libavformat/mux.c index 0227c0d..9bac252 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1227,11 +1227,9 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt) for (;; ) { AVPacket opkt; int ret = interleave_packet(s, &opkt, pkt, flush); - if (pkt) { - memset(pkt, 0, sizeof(*pkt)); - av_init_packet(pkt); + if (pkt) pkt = NULL; - } + if (ret <= 0) //FIXME cleanup needed for ret<0 ? return ret;