Browse code

ffprobe: fix crash if the file can't be opened.

Clément Bœsch authored on 2012/02/19 05:34:44
Showing 1 changed files
... ...
@@ -1627,9 +1627,9 @@ static int probe_file(WriterContext *wctx, const char *filename)
1627 1627
     do_read_packets = do_show_packets || do_count_packets;
1628 1628
 
1629 1629
     ret = open_input_file(&fmt_ctx, filename);
1630
-    nb_streams_frames  = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_frames));
1631
-    nb_streams_packets = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_packets));
1632 1630
     if (ret >= 0) {
1631
+        nb_streams_frames  = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_frames));
1632
+        nb_streams_packets = av_calloc(fmt_ctx->nb_streams, sizeof(*nb_streams_packets));
1633 1633
         if (do_read_frames || do_read_packets) {
1634 1634
             const char *chapter;
1635 1635
             if (do_show_frames && do_show_packets &&
... ...
@@ -1651,11 +1651,9 @@ static int probe_file(WriterContext *wctx, const char *filename)
1651 1651
             if (fmt_ctx->streams[i]->codec->codec_id != CODEC_ID_NONE)
1652 1652
                 avcodec_close(fmt_ctx->streams[i]->codec);
1653 1653
         avformat_close_input(&fmt_ctx);
1654
+        av_freep(&nb_streams_frames);
1655
+        av_freep(&nb_streams_packets);
1654 1656
     }
1655
-
1656
-    av_freep(&nb_streams_frames);
1657
-    av_freep(&nb_streams_packets);
1658
-
1659 1657
     return ret;
1660 1658
 }
1661 1659