diff mbox

[FFmpeg-devel] lavfi/testsrc2: fix hang with very small sizes.

Message ID 20171030091418.24166-1-george@nsup.org
State Accepted
Commit a8305b0ea3ccfe00a50cd3312bfcc455c78aacb5
Headers show

Commit Message

Nicolas George Oct. 30, 2017, 9:14 a.m. UTC
Move a subtraction to the other side of the equal to avoid overflows.

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavfilter/vsrc_testsrc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Martin Vignali Oct. 30, 2017, 11:40 p.m. UTC | #1
2017-10-30 10:14 GMT+01:00 Nicolas George <george@nsup.org>:

> Move a subtraction to the other side of the equal to avoid overflows.
>
> Signed-off-by: Nicolas George <george@nsup.org>
> ---
>  libavfilter/vsrc_testsrc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
> index fe0d50aa41..a790974d14 100644
> --- a/libavfilter/vsrc_testsrc.c
> +++ b/libavfilter/vsrc_testsrc.c
> @@ -857,8 +857,8 @@ static void test2_fill_picture(AVFilterContext *ctx,
> AVFrame *frame)
>          uint8_t alpha[256];
>
>          r = s->pts;
> -        for (y = ymin; y < ymax - 15; y += 16) {
> -            for (x = xmin; x < xmax - 15; x += 16) {
> +        for (y = ymin; y + 15 < ymax; y += 16) {
> +            for (x = xmin; x + 15 < xmax; x += 16) {
>                  if ((x ^ y) & 16)
>                      continue;
>                  for (i = 0; i < 256; i++) {
> --
> 2.14.2


lgtm
Nicolas George Oct. 31, 2017, 8:50 a.m. UTC | #2
Le decadi 10 brumaire, an CCXXVI, Martin Vignali a écrit :
> lgtm

Thanks, pushed.

Regards,
diff mbox

Patch

diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index fe0d50aa41..a790974d14 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -857,8 +857,8 @@  static void test2_fill_picture(AVFilterContext *ctx, AVFrame *frame)
         uint8_t alpha[256];
 
         r = s->pts;
-        for (y = ymin; y < ymax - 15; y += 16) {
-            for (x = xmin; x < xmax - 15; x += 16) {
+        for (y = ymin; y + 15 < ymax; y += 16) {
+            for (x = xmin; x + 15 < xmax; x += 16) {
                 if ((x ^ y) & 16)
                     continue;
                 for (i = 0; i < 256; i++) {