[spice-gtk v1 1/2] gtk-session: clipboard: avoid possible index out of bounds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

Should first check selection value before accessing those arrays.
The get_clipboard_from_selection() function does that for us.

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---
 src/spice-gtk-session.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 32f857d..1a19bca 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -1014,15 +1014,14 @@ static gboolean clipboard_request(SpiceMainChannel *main, guint selection,
     GtkClipboard* cb;
     int m;
 
+    cb = get_clipboard_from_selection(s, selection);
+    g_return_val_if_fail(cb != NULL, FALSE);
     g_return_val_if_fail(s->clipboard_by_guest[selection] == FALSE, FALSE);
     g_return_val_if_fail(s->clip_grabbed[selection], FALSE);
 
     if (read_only(self))
         return FALSE;
 
-    cb = get_clipboard_from_selection(s, selection);
-    g_return_val_if_fail(cb != NULL, FALSE);
-
     if (type == VD_AGENT_CLIPBOARD_UTF8_TEXT) {
         gtk_clipboard_request_text(cb, clipboard_received_text_cb,
                                    get_weak_ref(self));
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]