Sophie

Sophie

distrib > Mageia > 9 > armv7hl > by-pkgid > 70db79aeb6f762d1452a58a64b648349 > files > 6

afterstep-2.2.12-22.mga9.src.rpm

From ee7ccd61809477f66410d0a5e4c278614e8362dc Mon Sep 17 00:00:00 2001
From: Sasha Vasko <sasha@aftercode.net>
Date: Sat, 23 Nov 2013 23:08:17 -0600
Subject: [PATCH 06/18] fixed segfault due to wrong pointer in dbus add watch
 handler

---
 src/afterstep/dbus.c   |  4 ++--
 src/afterstep/events.c | 13 +++++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/afterstep/dbus.c b/src/afterstep/dbus.c
index c8214604..2e29fc47 100644
--- a/src/afterstep/dbus.c
+++ b/src/afterstep/dbus.c
@@ -226,7 +226,7 @@ static dbus_bool_t add_watch(DBusWatch *w, void *data)
 	if (ASDBus.watchFds == NULL)
 		ASDBus.watchFds = create_asvector (sizeof(ASDBusFd*));
 
-	append_vector(ASDBus.watchFds, fd, 1);
+	append_vector(ASDBus.watchFds, &fd, 1);
 
 	show_progress("added dbus watch fd=%d watch=%p readable =%d\n", fd->fd, w, fd->readable);
 	return TRUE;
@@ -236,7 +236,7 @@ static void remove_watch(DBusWatch *w, void *data)
 {
     ASDBusFd* fd = dbus_watch_get_data(w);
 
-    vector_remove_elem (ASDBus.watchFds, fd);
+    vector_remove_elem (ASDBus.watchFds, &fd);
     dbus_watch_set_data(w, NULL, NULL);
     show_progress("removed dbus watch watch=%p\n", w);
 }
diff --git a/src/afterstep/events.c b/src/afterstep/events.c
index 25d03603..dcdcecb5 100644
--- a/src/afterstep/events.c
+++ b/src/afterstep/events.c
@@ -1782,14 +1782,21 @@ void afterstep_wait_pipes_input (int timeout_sec)
 #define AS_FD_SET(fd,fdset) \
 	do{ if (fd>=0) { FD_SET((fd),(fdset)); if ((fd)>max_fd) max_fd = (fd);}}while(0)
 
+	LOCAL_DEBUG_OUT ("asdbus_fds = %p", asdbus_fds);
 	if (asdbus_fds != NULL) {
 		register int i;
+		LOCAL_DEBUG_OUT ("asdbus_fds->used = %d", asdbus_fds->used);
 		for ( i = 0 ; i < asdbus_fds->used; ++i) {
 			ASDBusFd* fd = PVECTOR_HEAD(ASDBusFd*,asdbus_fds)[i];
-			if (fd->readable)
+			LOCAL_DEBUG_OUT ("asdbus_fds[%d] = %p", i, fd);
+			if (fd && fd->readable){
+				LOCAL_DEBUG_OUT ("asdbus_fds[%d].fd = %d", i, fd->fd);
 				AS_FD_SET (fd->fd, &in_fdset);
+			}
 		}
 	}
+	LOCAL_DEBUG_OUT ("done with asdbus_fds", "");
+
 	AS_FD_SET (Module_fd, &in_fdset);
 
 	if (Modules != NULL) {				/* adding all the modules pipes to our wait list */
@@ -1844,8 +1851,10 @@ void afterstep_wait_pipes_input (int timeout_sec)
 			register int i;
 			for ( i = 0 ; i < asdbus_fds->used; ++i) {
 				ASDBusFd* fd = PVECTOR_HEAD(ASDBusFd*,asdbus_fds)[i];
-				if (FD_ISSET (fd->fd, &in_fdset))
+				if (fd && FD_ISSET (fd->fd, &in_fdset)){
 					asdbus_process_messages (fd);
+					break;
+				}
 			}
 		}
 	}
-- 
2.22.0