ffprobe: change order of operations in probe_file()
authorStefano Sabatini <stefasab@gmail.com>
Thu, 29 Dec 2011 11:50:25 +0000 (12:50 +0100)
committerStefano Sabatini <stefasab@gmail.com>
Wed, 4 Jan 2012 00:05:56 +0000 (01:05 +0100)
This is required by a pending patch, also fixes a memleak due to the
writer context not being closed in case of open_input_file() failure.

ffprobe.c

index ddeaeee..42832d7 100644 (file)
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -1399,16 +1399,16 @@ static int probe_file(const char *filename)
 
     if ((ret = writer_open(&wctx, w, w_args, NULL)) < 0)
         goto end;
-    if ((ret = open_input_file(&fmt_ctx, filename)))
-        goto end;
 
     writer_print_header(wctx);
+    ret = open_input_file(&fmt_ctx, filename);
+    if (ret >= 0) {
     PRINT_CHAPTER(packets);
     PRINT_CHAPTER(streams);
     PRINT_CHAPTER(format);
-    writer_print_footer(wctx);
-
     avformat_close_input(&fmt_ctx);
+    }
+    writer_print_footer(wctx);
     writer_close(&wctx);
 
 end: