[FFmpeg-cvslog] filtfmts: Avoid null pointer dereference

Himangi Saraogi git at videolan.org
Fri Apr 3 17:33:05 CEST 2015


ffmpeg | branch: master | Himangi Saraogi <himangi774 at gmail.com> | Fri Apr  3 20:04:05 2015 +0530| [24326930d87dd7e851c1cc383bc0682d746ffaf8] | committer: Michael Niedermayer

filtfmts: Avoid null pointer dereference

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=24326930d87dd7e851c1cc383bc0682d746ffaf8
---

 libavfilter/filtfmts.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavfilter/filtfmts.c b/libavfilter/filtfmts.c
index c1025b9..46a2d94 100644
--- a/libavfilter/filtfmts.c
+++ b/libavfilter/filtfmts.c
@@ -75,6 +75,7 @@ int main(int argc, char **argv)
     const char *filter_name;
     const char *filter_args = NULL;
     int i;
+    int ret = 0;
 
     av_log_set_level(AV_LOG_DEBUG);
 
@@ -115,11 +116,21 @@ int main(int argc, char **argv)
     /* create a link for each of the input pads */
     for (i = 0; i < filter_ctx->nb_inputs; i++) {
         AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
+        if (!link) {
+            fprintf(stderr, "Unable to allocate memory for filter input link\n");
+            ret = 1;
+            goto fail;
+        }
         link->type = avfilter_pad_get_type(filter_ctx->input_pads, i);
         filter_ctx->inputs[i] = link;
     }
     for (i = 0; i < filter_ctx->nb_outputs; i++) {
         AVFilterLink *link = av_mallocz(sizeof(AVFilterLink));
+        if (!link) {
+            fprintf(stderr, "Unable to allocate memory for filter output link\n");
+            ret = 1;
+            goto fail;
+        }
         link->type = avfilter_pad_get_type(filter_ctx->output_pads, i);
         filter_ctx->outputs[i] = link;
     }
@@ -131,8 +142,9 @@ int main(int argc, char **argv)
 
     print_formats(filter_ctx);
 
+fail:
     avfilter_free(filter_ctx);
     avfilter_graph_free(&graph_ctx);
     fflush(stdout);
-    return 0;
+    return ret;
 }



More information about the ffmpeg-cvslog mailing list