[FFmpeg-cvslog] filtfmts: Avoid null pointer dereference

Himangi Saraogi git at videolan.org
Mon Apr 20 12:00:02 CEST 2015


ffmpeg | branch: master | Himangi Saraogi <himangi774 at gmail.com> | Fri Apr  3 20:00:11 2015 +0530| [88d1fb4e3f156d8fd5bb6cb3ba3a9ef1e6d6fb08] | committer: Vittorio Giovara

filtfmts: Avoid null pointer dereference

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

 libavfilter/filtfmts.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavfilter/filtfmts.c b/libavfilter/filtfmts.c
index 40649c7..cc04654 100644
--- a/libavfilter/filtfmts.c
+++ b/libavfilter/filtfmts.c
@@ -33,7 +33,7 @@ int main(int argc, char **argv)
     AVFilterGraph *graph_ctx;
     const char *filter_name;
     const char *filter_args = NULL;
-    int i, j;
+    int i, j, ret = 0;
 
     av_log_set_level(AV_LOG_DEBUG);
 
@@ -74,11 +74,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->filter->inputs, 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->filter->outputs, i);
         filter_ctx->outputs[i] = link;
     }
@@ -106,8 +116,9 @@ int main(int argc, char **argv)
                    av_get_pix_fmt_name(fmts->formats[j]));
     }
 
+fail:
     avfilter_free(filter_ctx);
     avfilter_graph_free(&graph_ctx);
     fflush(stdout);
-    return 0;
+    return ret;
 }



More information about the ffmpeg-cvslog mailing list