aboutsummaryrefslogtreecommitdiffstats
path: root/avprobe.c
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2012-05-14 12:23:10 +0200
committerJanne Grunau <janne-libav@jannau.net>2012-05-14 18:37:20 +0200
commit093c50a4f6402bd0481df03e43fbba1dc3630f49 (patch)
treeb40e8f57cc441f99241505989311becc4836b249 /avprobe.c
parent100c70b0481b889d522b4fc2aac5b948ddb05c70 (diff)
downloadffmpeg-093c50a4f6402bd0481df03e43fbba1dc3630f49.tar.gz
avprobe: close opened codecs after use
Fixes "memleak" on closing avprobe to make valgrind happy.
Diffstat (limited to 'avprobe.c')
-rw-r--r--avprobe.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/avprobe.c b/avprobe.c
index 8d2ec24042..a3c1f80952 100644
--- a/avprobe.c
+++ b/avprobe.c
@@ -352,6 +352,20 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
return 0;
}
+static void close_input_file(AVFormatContext **ctx_ptr)
+{
+ int i;
+ AVFormatContext *fmt_ctx = *ctx_ptr;
+
+ /* close decoder for each stream */
+ for (i = 0; i < fmt_ctx->nb_streams; i++) {
+ AVStream *stream = fmt_ctx->streams[i];
+
+ avcodec_close(stream->codec);
+ }
+ avformat_close_input(ctx_ptr);
+}
+
static int probe_file(const char *filename)
{
AVFormatContext *fmt_ctx;
@@ -370,7 +384,7 @@ static int probe_file(const char *filename)
if (do_show_format)
show_format(fmt_ctx);
- avformat_close_input(&fmt_ctx);
+ close_input_file(&fmt_ctx);
return 0;
}