Commit 89909a18c1 for ffmpeg
commit 89909a18c1cd7d17bb48a03e1d73fdb53d5d7ff1
Author: zhang xingxing <2388969553@qq.com>
Date: Mon Sep 21 06:10:49 2026 +0200
avfilter/vf_huesaturation: skip the luminance shear when the luminance vector is zero
Found-by: zhang xingxing
Fixes: float division by 0
Fixes: WgQdanA8nq8x
Fixes: swarm-Division-by-zero-in-hue-rotation-with-zero-weights-bda2e7
diff --git a/libavfilter/vf_huesaturation.c b/libavfilter/vf_huesaturation.c
index 6a4aadeee1..6fdb39bafb 100644
--- a/libavfilter/vf_huesaturation.c
+++ b/libavfilter/vf_huesaturation.c
@@ -321,8 +321,8 @@ static void hue_rotate_matrix(float matrix[4][4], float rotation,
y_rotate_matrix(matrix, yrs, yrc);
transform_point(matrix, rlw, glw, blw, &lx, &ly, &lz);
- zsx = lx / lz;
- zsy = ly / lz;
+ zsx = lz ? lx / lz : 0.f;
+ zsy = lz ? ly / lz : 0.f;
z_shear_matrix(matrix, zsx, zsy);
zrs = sinf(rotation * M_PI / 180.f);