Message ID | 20191021024934.1624-4-jamrial@gmail.com |
---|---|
State | New |
Headers | show |
On 10/20/2019 11:49 PM, James Almer wrote: > If the trailer is never writen, there could be buffered pages that would leak. Much like the avi patch i sent the other day, this fix also depends on "avformat: call AVOutputFormat->deinit() when freeing the context". > > Signed-off-by: James Almer <jamrial@gmail.com> > --- > libavformat/oggenc.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c > index 06021c4f4b..77aa2518dc 100644 > --- a/libavformat/oggenc.c > +++ b/libavformat/oggenc.c > @@ -740,6 +740,8 @@ static int ogg_write_trailer(AVFormatContext *s) > > static void ogg_free(AVFormatContext *s) > { > + OGGContext *ogg = s->priv_data; > + OGGPageList *p = ogg->page_list; > int i; > > for (i = 0; i < s->nb_streams; i++) { > @@ -756,6 +758,12 @@ static void ogg_free(AVFormatContext *s) > av_freep(&oggstream->header[1]); > av_freep(&st->priv_data); > } > + > + while (p) { > + OGGPageList *next = p->next; > + av_free(p); > + p = next; > + } > } > > #if CONFIG_OGG_MUXER >
James Almer: > If the trailer is never writen, there could be buffered pages that would leak. > Typo ("writen") in the commit message. > Signed-off-by: James Almer <jamrial@gmail.com> > --- > libavformat/oggenc.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c > index 06021c4f4b..77aa2518dc 100644 > --- a/libavformat/oggenc.c > +++ b/libavformat/oggenc.c > @@ -740,6 +740,8 @@ static int ogg_write_trailer(AVFormatContext *s) > > static void ogg_free(AVFormatContext *s) > { > + OGGContext *ogg = s->priv_data; > + OGGPageList *p = ogg->page_list; > int i; > > for (i = 0; i < s->nb_streams; i++) { > @@ -756,6 +758,12 @@ static void ogg_free(AVFormatContext *s) > av_freep(&oggstream->header[1]); > av_freep(&st->priv_data); > } > + > + while (p) { > + OGGPageList *next = p->next; > + av_free(p); > + p = next; > + } > } > > #if CONFIG_OGG_MUXER > You could also set ogg->page_list to NULL in order not to leave any dangling pointers behind. - Andreas
On 10/21/2019 5:34 AM, Andreas Rheinhardt wrote: > James Almer: >> If the trailer is never writen, there could be buffered pages that would leak. >> > Typo ("writen") in the commit message. > >> Signed-off-by: James Almer <jamrial@gmail.com> >> --- >> libavformat/oggenc.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c >> index 06021c4f4b..77aa2518dc 100644 >> --- a/libavformat/oggenc.c >> +++ b/libavformat/oggenc.c >> @@ -740,6 +740,8 @@ static int ogg_write_trailer(AVFormatContext *s) >> >> static void ogg_free(AVFormatContext *s) >> { >> + OGGContext *ogg = s->priv_data; >> + OGGPageList *p = ogg->page_list; >> int i; >> >> for (i = 0; i < s->nb_streams; i++) { >> @@ -756,6 +758,12 @@ static void ogg_free(AVFormatContext *s) >> av_freep(&oggstream->header[1]); >> av_freep(&st->priv_data); >> } >> + >> + while (p) { >> + OGGPageList *next = p->next; >> + av_free(p); >> + p = next; >> + } >> } >> >> #if CONFIG_OGG_MUXER >> You could also set ogg->page_list to NULL in order not to leave any > dangling pointers behind. > > - Andreas Changed, and patchset pushed. Thanks.
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index 06021c4f4b..77aa2518dc 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -740,6 +740,8 @@ static int ogg_write_trailer(AVFormatContext *s) static void ogg_free(AVFormatContext *s) { + OGGContext *ogg = s->priv_data; + OGGPageList *p = ogg->page_list; int i; for (i = 0; i < s->nb_streams; i++) { @@ -756,6 +758,12 @@ static void ogg_free(AVFormatContext *s) av_freep(&oggstream->header[1]); av_freep(&st->priv_data); } + + while (p) { + OGGPageList *next = p->next; + av_free(p); + p = next; + } } #if CONFIG_OGG_MUXER
If the trailer is never writen, there could be buffered pages that would leak. Signed-off-by: James Almer <jamrial@gmail.com> --- libavformat/oggenc.c | 8 ++++++++ 1 file changed, 8 insertions(+)