Fix the iformat/oformat typo and make the function behave if
the context is already NULL.
---
 libavformat/utils.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8b749ad..865edbc 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3222,6 +3222,9 @@ int av_write_trailer(AVFormatContext *s)
 {
     int ret, i;
 
+    if (!s || !s->oformat)
+        return 0;
+
     for(;;){
         AVPacket pkt;
         ret= interleave_packet(s, &pkt, NULL, 1);
@@ -3247,7 +3250,7 @@ fail:
         av_freep(&s->streams[i]->priv_data);
         av_freep(&s->streams[i]->index_entries);
     }
-    if (s->iformat && s->iformat->priv_class)
+    if (s->oformat->priv_class)
         av_opt_free(s->priv_data);
     av_freep(&s->priv_data);
     return ret;
-- 
1.7.8.rc1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to