Blob Blame History Raw
From e521ddee98961bb30a7a3d93c6c01dddb7da3662 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
Date: Tue, 15 Sep 2020 13:09:46 +0400
Subject: [PATCH] main: add stricter pre-condition on display id value
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
---
 src/channel-main.c | 4 ++--
 1 file 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;
-- 
2.28.0