mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-08-12 22:16:21 +00:00
checkasm/sw_rgb: fix too small source stride in uyvytoyuv422 test
The planes table stored a source stride smaller than the 2*width bytes a packed UYVY line occupies (e.g. width 12 with stride 12), and the correct stride for width 128 would be 256, which does not even fit the uint8_t field. The test passed only because the oversized source buffer absorbed the resulting out-of-bounds reads. Derive srcStride from the width (2*width) instead of storing it, so each line is passed its true size. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
michaelni
parent
b1327568b6
commit
d5a2ab9c08
@@ -38,8 +38,8 @@
|
||||
} while (0)
|
||||
|
||||
static const uint8_t width[] = {12, 16, 20, 32, 36, 128};
|
||||
static const struct {uint8_t w, h, s;} planes[] = {
|
||||
{12,16,12}, {16,16,16}, {20,23,25}, {32,18,48}, {8,128,16}, {128,128,128}
|
||||
static const struct {uint8_t w, h;} planes[] = {
|
||||
{12,16}, {16,16}, {20,23}, {32,18}, {8,128}, {128,128}
|
||||
};
|
||||
|
||||
#define MAX_STRIDE 128
|
||||
@@ -93,6 +93,9 @@ static void check_uyvy_to_422p(void)
|
||||
|
||||
if (check_func(uyvytoyuv422, "uyvytoyuv422")) {
|
||||
for (i = 0; i < 6; i ++) {
|
||||
int w = planes[i].w, h = planes[i].h;
|
||||
int srcStride = 2 * w;
|
||||
|
||||
memset(dst_y_0, 0, MAX_STRIDE * MAX_HEIGHT);
|
||||
memset(dst_y_1, 0, MAX_STRIDE * MAX_HEIGHT);
|
||||
memset(dst_u_0, 0, (MAX_STRIDE/2) * MAX_HEIGHT);
|
||||
@@ -100,17 +103,17 @@ static void check_uyvy_to_422p(void)
|
||||
memset(dst_v_0, 0, (MAX_STRIDE/2) * MAX_HEIGHT);
|
||||
memset(dst_v_1, 0, (MAX_STRIDE/2) * MAX_HEIGHT);
|
||||
|
||||
call_ref(dst_y_0, dst_u_0, dst_v_0, src0, planes[i].w, planes[i].h,
|
||||
MAX_STRIDE, MAX_STRIDE / 2, planes[i].s);
|
||||
call_new(dst_y_1, dst_u_1, dst_v_1, src1, planes[i].w, planes[i].h,
|
||||
MAX_STRIDE, MAX_STRIDE / 2, planes[i].s);
|
||||
call_ref(dst_y_0, dst_u_0, dst_v_0, src0, w, h,
|
||||
MAX_STRIDE, MAX_STRIDE / 2, srcStride);
|
||||
call_new(dst_y_1, dst_u_1, dst_v_1, src1, w, h,
|
||||
MAX_STRIDE, MAX_STRIDE / 2, srcStride);
|
||||
if (memcmp(dst_y_0, dst_y_1, MAX_STRIDE * MAX_HEIGHT) ||
|
||||
memcmp(dst_u_0, dst_u_1, (MAX_STRIDE/2) * MAX_HEIGHT) ||
|
||||
memcmp(dst_v_0, dst_v_1, (MAX_STRIDE/2) * MAX_HEIGHT))
|
||||
fail();
|
||||
}
|
||||
bench_new(dst_y_1, dst_u_1, dst_v_1, src1, planes[5].w, planes[5].h,
|
||||
MAX_STRIDE, MAX_STRIDE / 2, planes[5].s);
|
||||
MAX_STRIDE, MAX_STRIDE / 2, 2 * planes[5].w);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user