Commit 04955e8b14 for ffmpeg
commit 04955e8b148fa3e7ab022cbb9f5e35c49165ae21
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Sat Nov 14 01:58:22 2026 +0100
avfilter/vf_signalstats: allocate the histograms for all 16 bit sample values
Fixes: out of array write
Fixes: 91956.4 is outside the range of representable values of type 'unsigned short'
Fixes: 3DKcZFM0ZaFw
Fixes: AISLE-2026-0166-00233
Found-by: Joshua Rogers (AISLE)
Out of array write Replicated through UnModified FFmpeg with ASAN
Float to integer overflow Replicated through UnModified FFmpeg with UBSAN
diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 5859b46478..a69773c208 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -161,10 +161,10 @@ static int config_output(AVFilterLink *outlink)
s->vsub = desc->log2_chroma_h;
s->depth = desc->comp[0].depth;
s->maxsize = 1 << s->depth;
- s->histy = av_malloc_array(s->maxsize, sizeof(*s->histy));
- s->histu = av_malloc_array(s->maxsize, sizeof(*s->histu));
- s->histv = av_malloc_array(s->maxsize, sizeof(*s->histv));
- s->histsat = av_malloc_array(s->maxsize, sizeof(*s->histsat));
+ s->histy = av_calloc(1 << (s->depth > 8 ? 16 : 8), sizeof(*s->histy));
+ s->histu = av_calloc(1 << (s->depth > 8 ? 16 : 8), sizeof(*s->histu));
+ s->histv = av_calloc(1 << (s->depth > 8 ? 16 : 8), sizeof(*s->histv));
+ s->histsat = av_calloc(1 << (s->depth > 8 ? 16 : 8), sizeof(*s->histsat));
if (!s->histy || !s->histu || !s->histv || !s->histsat)
return AVERROR(ENOMEM);
@@ -520,7 +520,7 @@ static int compute_sat_hue_metrics16(AVFilterContext *ctx, void *arg, int jobnr,
for (i = 0; i < s->chromaw; i++) {
const int yuvu = p_u[i];
const int yuvv = p_v[i];
- p_sat[i] = hypotf(yuvu - mid, yuvv - mid); // int or round?
+ p_sat[i] = (int)hypotf(yuvu - mid, yuvv - mid); // int or round?
((int16_t*)p_hue)[i] = fmodf(floorf((180.f / M_PI) * atan2f(yuvu-mid, yuvv-mid) + 180.f), 360.f);
}
p_u += lsz_u;