avfilter/vsrc_testsrc: draw_bar: make sure width is not negative
authorPaul B Mahol <onemda@gmail.com>
Thu, 15 Dec 2016 14:52:48 +0000 (15:52 +0100)
committerPaul B Mahol <onemda@gmail.com>
Thu, 15 Dec 2016 15:03:48 +0000 (16:03 +0100)
Reported-by: Josh de Kock
Signed-off-by: Paul B Mahol <onemda@gmail.com>
libavfilter/vsrc_testsrc.c

index 08f6e07..422f6d8 100644 (file)
@@ -1309,8 +1309,8 @@ static void draw_bar(TestSourceContext *test, const uint8_t color[4],
 
     x = FFMIN(x, test->w - 1);
     y = FFMIN(y, test->h - 1);
-    w = FFMIN(w, test->w - x);
-    h = FFMIN(h, test->h - y);
+    w = FFMAX(FFMIN(w, test->w - x), 0);
+    h = FFMAX(FFMIN(h, test->h - y), 0);
 
     av_assert0(x + w <= test->w);
     av_assert0(y + h <= test->h);