OSDN Git Service

ffprobe: set writer context to 0 after allocation
authorStefano Sabatini <stefasab@gmail.com>
Tue, 19 Mar 2013 16:57:50 +0000 (17:57 +0100)
committerStefano Sabatini <stefasab@gmail.com>
Tue, 19 Mar 2013 17:00:34 +0000 (18:00 +0100)
Avoid access to uninitialized values, which may result in a crash.

This happens for example in case of option parsing failure, since in that
case the internal AVBprint buffers are not initialized.

ffprobe.c

index ef9bef4..4d2d3e1 100644 (file)
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -300,7 +300,7 @@ static int writer_open(WriterContext **wctx, const Writer *writer, const char *a
 {
     int i, ret = 0;
 
-    if (!(*wctx = av_malloc(sizeof(WriterContext)))) {
+    if (!(*wctx = av_mallocz(sizeof(WriterContext)))) {
         ret = AVERROR(ENOMEM);
         goto fail;
     }