Blame SOURCES/0002-registryd-Avoid-crashing-with-a-NULL-keystring.patch

4fe018
From 662a5454c127037627e8e5a7e3f2b5cbeb1c44f1 Mon Sep 17 00:00:00 2001
4fe018
From: Rui Matos <tiagomatos@gmail.com>
4fe018
Date: Wed, 6 Apr 2016 16:40:44 +0200
4fe018
Subject: [PATCH 2/4] registryd: Avoid crashing with a NULL keystring
4fe018
4fe018
From a coverity check:
4fe018
4fe018
1. at-spi2-core-2.14.1/registryd/deviceeventcontroller-x11.c:1167:
4fe018
deref_ptr_in_call: Dereferencing pointer "keystring".
4fe018
2. at-spi2-core-2.14.1/registryd/deviceeventcontroller-x11.c:1169:
4fe018
check_after_deref: Null-checking "keystring" suggests that it may be
4fe018
null, but it has already been dereferenced on all paths leading to the
4fe018
check.
4fe018
(keystring, -1, &c))) {
4fe018
---
4fe018
 registryd/deviceeventcontroller-x11.c | 8 +++++---
4fe018
 1 file changed, 5 insertions(+), 3 deletions(-)
4fe018
4fe018
diff --git a/registryd/deviceeventcontroller-x11.c b/registryd/deviceeventcontroller-x11.c
4fe018
index d878d53..e003c00 100644
4fe018
--- a/registryd/deviceeventcontroller-x11.c
4fe018
+++ b/registryd/deviceeventcontroller-x11.c
4fe018
@@ -1164,8 +1164,6 @@ spi_dec_x11_synth_keystring (SpiDEController *controller, guint synth_type, gint
4fe018
 	const gchar *c;
4fe018
 	KeySym keysym;
4fe018
 
4fe018
-	maxlen = strlen (keystring) + 1;
4fe018
-	keysyms = g_new0 (KeySym, maxlen);
4fe018
 	if (!(keystring && *keystring && g_utf8_validate (keystring, -1, &c))) { 
4fe018
 		retval = FALSE;
4fe018
 	} 
4fe018
@@ -1173,6 +1171,9 @@ spi_dec_x11_synth_keystring (SpiDEController *controller, guint synth_type, gint
4fe018
 #ifdef SPI_DEBUG
4fe018
 		fprintf (stderr, "[keystring synthesis attempted on %s]\n", keystring);
4fe018
 #endif
4fe018
+		maxlen = strlen (keystring) + 1;
4fe018
+		keysyms = g_new0 (KeySym, maxlen);
4fe018
+
4fe018
 		while (keystring && (unichar = g_utf8_get_char (keystring))) {
4fe018
 			char bytes[6];
4fe018
 			gint mbytes;
4fe018
@@ -1206,8 +1207,9 @@ spi_dec_x11_synth_keystring (SpiDEController *controller, guint synth_type, gint
4fe018
 			}
4fe018
 		}
4fe018
 		XSynchronize (spi_get_display (), FALSE);
4fe018
+
4fe018
+		g_free (keysyms);
4fe018
 	}
4fe018
-	g_free (keysyms);
4fe018
 
4fe018
 	if (synth_type == Accessibility_KEY_SYM) {
4fe018
 		keysym = keycode;
4fe018
-- 
4fe018
2.5.0
4fe018