mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2024-12-25 21:59:11 +01:00
test/alloc: check test_layer.compat length
Avoid iterating past the array bounds as a safety net. We should have more than enough room for now, but let's make sure we don't get caught.
This commit is contained in:
parent
3ced3be25a
commit
32f97b1c51
1 changed files with 7 additions and 2 deletions
|
@ -662,7 +662,7 @@ test_needs_composition(const struct test_layer *test_layers)
|
||||||
static void
|
static void
|
||||||
run_test(const struct test_layer *test_layers)
|
run_test(const struct test_layer *test_layers)
|
||||||
{
|
{
|
||||||
size_t i, j;
|
size_t i, j, len;
|
||||||
ssize_t plane_index_got, plane_index_want;
|
ssize_t plane_index_got, plane_index_want;
|
||||||
struct liftoff_mock_plane *mock_planes[64];
|
struct liftoff_mock_plane *mock_planes[64];
|
||||||
struct liftoff_mock_plane *mock_plane;
|
struct liftoff_mock_plane *mock_plane;
|
||||||
|
@ -692,19 +692,24 @@ run_test(const struct test_layer *test_layers)
|
||||||
output = liftoff_output_create(device, liftoff_mock_drm_crtc_id);
|
output = liftoff_output_create(device, liftoff_mock_drm_crtc_id);
|
||||||
for (i = 0; test_layers[i].width > 0; i++) {
|
for (i = 0; test_layers[i].width > 0; i++) {
|
||||||
test_layer = &test_layers[i];
|
test_layer = &test_layers[i];
|
||||||
|
|
||||||
layers[i] = add_layer(output, test_layer->x, test_layer->y,
|
layers[i] = add_layer(output, test_layer->x, test_layer->y,
|
||||||
test_layer->width, test_layer->height);
|
test_layer->width, test_layer->height);
|
||||||
|
|
||||||
if (test_layer->zpos != 0) {
|
if (test_layer->zpos != 0) {
|
||||||
liftoff_layer_set_property(layers[i], "zpos",
|
liftoff_layer_set_property(layers[i], "zpos",
|
||||||
test_layer->zpos);
|
test_layer->zpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_layer->composition) {
|
if (test_layer->composition) {
|
||||||
liftoff_output_set_composition_layer(output, layers[i]);
|
liftoff_output_set_composition_layer(output, layers[i]);
|
||||||
}
|
}
|
||||||
if (test_layer->force_composited) {
|
if (test_layer->force_composited) {
|
||||||
liftoff_layer_set_fb_composited(layers[i]);
|
liftoff_layer_set_fb_composited(layers[i]);
|
||||||
}
|
}
|
||||||
for (j = 0; test_layer->compat[j] != NULL; j++) {
|
|
||||||
|
len = sizeof(test_layer->compat) / sizeof(test_layer->compat[0]);
|
||||||
|
for (j = 0; j < len && test_layer->compat[j] != NULL; j++) {
|
||||||
mock_plane = mock_planes[test_layer->compat[j] -
|
mock_plane = mock_planes[test_layer->compat[j] -
|
||||||
test_setup];
|
test_setup];
|
||||||
liftoff_mock_plane_add_compatible_layer(mock_plane,
|
liftoff_mock_plane_add_compatible_layer(mock_plane,
|
||||||
|
|
Loading…
Reference in a new issue