]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_signalstats: fix stack buffer overflow
authorPaul B Mahol <onemda@gmail.com>
Fri, 11 Oct 2019 11:32:24 +0000 (13:32 +0200)
committerPaul B Mahol <onemda@gmail.com>
Fri, 11 Oct 2019 11:32:24 +0000 (13:32 +0200)
Fixes #8249

libavfilter/vf_signalstats.c

index 2b8c0de4c4d58a213df0e444c3d97a29cd852827..abe813d91df4cd896ab7da4e6491f0747223d17c 100644 (file)
@@ -491,7 +491,7 @@ static int compute_sat_hue_metrics8(AVFilterContext *ctx, void *arg, int jobnr,
             const int yuvu = p_u[i];
             const int yuvv = p_v[i];
             p_sat[i] = hypot(yuvu - 128, yuvv - 128); // int or round?
-            ((int16_t*)p_hue)[i] = floor((180 / M_PI) * atan2f(yuvu-128, yuvv-128) + 180);
+            ((int16_t*)p_hue)[i] = fmod(floor((180 / M_PI) * atan2f(yuvu-128, yuvv-128) + 180), 360.);
         }
         p_u   += lsz_u;
         p_v   += lsz_v;
@@ -530,7 +530,7 @@ static int compute_sat_hue_metrics16(AVFilterContext *ctx, void *arg, int jobnr,
             const int yuvu = p_u[i];
             const int yuvv = p_v[i];
             p_sat[i] = hypot(yuvu - mid, yuvv - mid); // int or round?
-            ((int16_t*)p_hue)[i] = floor((180 / M_PI) * atan2f(yuvu-mid, yuvv-mid) + 180);
+            ((int16_t*)p_hue)[i] = fmod(floor((180 / M_PI) * atan2f(yuvu-mid, yuvv-mid) + 180), 360.);
         }
         p_u   += lsz_u;
         p_v   += lsz_v;