avfilter/vf_pad: Fix segfault if reconfiguration fails
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 2 Jan 2017 17:19:54 +0000 (18:19 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 2 Jan 2017 17:42:31 +0000 (18:42 +0100)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavfilter/vf_pad.c

index 9739a0f..61927b6 100644 (file)
@@ -210,12 +210,16 @@ static int config_output(AVFilterLink *outlink)
 static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
 {
     PadContext *s = inlink->dst->priv;
-
-    AVFrame *frame = ff_get_video_buffer(inlink->dst->outputs[0],
-                                         w + (s->w - s->in_w),
-                                         h + (s->h - s->in_h) + (s->x > 0));
+    AVFrame *frame;
     int plane;
 
+    if (s->inlink_w <= 0)
+        return NULL;
+
+    frame = ff_get_video_buffer(inlink->dst->outputs[0],
+                                w + (s->w - s->in_w),
+                                h + (s->h - s->in_h) + (s->x > 0));
+
     if (!frame)
         return NULL;