util: pattern: Fix chroma offset for insert_value_yuv_planar

The chroma offset calculation resulted in the running beyond
the end of the buffer.

eg For ysub=2, y=0 and y=1 should result in writing the same U & V
line, but chroma_offset = (y + 1) / ysub; resulted in them going
to different lines, potentially running off the end of the buffer
and causing a seg fault.

Update the calculation so lines 0 to (ysub-1) all write the same
output line.

Fixes: 40aeab6fd5 ("modetest: util: pattern: add new patterns")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
This commit is contained in:
Dave Stevenson 2025-07-24 16:01:15 +01:00
parent 116076ef39
commit d06ea82901

View file

@ -1951,7 +1951,7 @@ static void insert_value_yuv_planar(const struct util_format_info *info,
unsigned int cs = yuv->chroma_stride;
unsigned int xsub = yuv->xsub;
unsigned int ysub = yuv->ysub;
unsigned int chroma_offset = (y + 1) / ysub;
unsigned int chroma_offset = y / ysub;
unsigned char *y_mem = planes[0] + (y * stride);
unsigned char *u_mem = planes[1];
unsigned char *v_mem = planes[2];