summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2020-09-15 13:09:46 +0400
committerFrediano Ziglio <freddy77@gmail.com>2020-09-16 10:55:03 +0100
commite521ddee98961bb30a7a3d93c6c01dddb7da3662 (patch)
tree19dedddea8765368a4e5b4feddc237bf5de9f14b
parentdc66d070363505d74811c11ea405423e49951c43 (diff)
main: add stricter pre-condition on display id value
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--src/channel-main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/channel-main.c b/src/channel-main.c
index 671716a..5fcf8e8 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -2723,7 +2723,7 @@ void spice_main_channel_update_display(SpiceMainChannel *channel, int id, int x,
c = SPICE_MAIN_CHANNEL(channel)->priv;
- g_return_if_fail(id < SPICE_N_ELEMENTS(c->display));
+ g_return_if_fail(id >= 0 && id < SPICE_N_ELEMENTS(c->display));
SpiceDisplayConfig display = {
.x = x, .y = y, .width = width, .height = height,
@@ -3040,7 +3040,7 @@ void spice_main_channel_update_display_enabled(SpiceMainChannel *channel, int id
c->display[i].display_state = display_state;
}
} else {
- g_return_if_fail(id < G_N_ELEMENTS(c->display));
+ g_return_if_fail(id >= 0 && id < G_N_ELEMENTS(c->display));
if (c->display[id].display_state == display_state)
return;
c->display[id].display_state = display_state;