add check for malloc and a bit untangling
 Signed-off-by: Walter Harms <[email protected]>

---
 src/watch.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/watch.c b/src/watch.c
index abbc265..c60d0c1 100644
--- a/src/watch.c
+++ b/src/watch.c
@@ -48,7 +48,8 @@ IceAddConnectionWatch (
     _IceWatchProc      *newWatchProc;
     int                        i;

-    if ((newWatchProc = malloc (sizeof (_IceWatchProc))) == NULL)
+    newWatchProc = malloc (sizeof (_IceWatchProc));
+    if ( !newWatchProc )
     {
        return (0);
     }
@@ -75,7 +76,11 @@ IceAddConnectionWatch (
     {
        _IceWatchedConnection *newWatchedConn =
            malloc (sizeof (_IceWatchedConnection));
-
+       if (!newWatchedConn)
+         {
+           IceRemoveConnectionWatch(watchProc,clientData);
+           return (0);
+         }
        newWatchedConn->iceConn = _IceConnectionObjs[i];
        newWatchedConn->next = NULL;

@@ -86,6 +91,7 @@ IceAddConnectionWatch (
     }

     return (1);
+
 }


@@ -143,6 +149,9 @@ _IceConnectionOpened (
            malloc (sizeof (_IceWatchedConnection));
        _IceWatchedConnection *watchedConn;

+       if (!newWatchedConn)
+         return ;
+
        watchedConn = watchProc->watched_connections;
        while (watchedConn && watchedConn->next)
            watchedConn = watchedConn->next;
-- 
2.1.4

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to