[FFmpeg-devel] [PATCH] filtfmts: Avoid null pointer dereferences

Himangi Saraogi himangi774 at gmail.com
Fri Apr 3 10:55:13 CEST 2015


---
 libavfilter/filtfmts.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavfilter/filtfmts.c b/libavfilter/filtfmts.c
index c1025b9..3e2a011 100644
--- a/libavfilter/filtfmts.c
+++ b/libavfilter/filtfmts.c
@@ -34,6 +34,7 @@ static void print_formats(AVFilterContext *filter_ctx)
 
 #define PRINT_FMTS(inout, outin, INOUT)                                 \
     for (i = 0; i < filter_ctx->nb_##inout##puts; i++) {                     \
+        if (filter_ctx->inout##puts[i]) {                               \
         if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) {   \
             AVFilterFormats *fmts =                                     \
                 filter_ctx->inout##puts[i]->outin##_formats;            \
@@ -61,6 +62,7 @@ static void print_formats(AVFilterContext *filter_ctx)
                        i, avfilter_pad_get_name(filter_ctx->inout##put_pads, i), buf); \
             }                                                           \
         }                                                               \
+        }                                                               \
     }                                                                   \
 
     PRINT_FMTS(in,  out, IN);
@@ -115,11 +117,15 @@ 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)
+            continue;
         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)
+            continue;
         link->type = avfilter_pad_get_type(filter_ctx->output_pads, i);
         filter_ctx->outputs[i] = link;
     }
-- 
1.9.1



More information about the ffmpeg-devel mailing list