Added wl_connection_create failure checks.
authorIskren Chernev <iskren.chernev@gmail.com>
Fri, 11 Mar 2011 12:43:10 +0000 (14:43 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Sun, 13 Mar 2011 02:56:49 +0000 (21:56 -0500)
wayland/connection.c
wayland/wayland-client.c
wayland/wayland-server.c

index 4a00470..0d705b5 100644 (file)
@@ -160,6 +160,8 @@ wl_connection_create(int fd,
        struct wl_connection *connection;
 
        connection = malloc(sizeof *connection);
+       if (connection == NULL)
+               return NULL;
        memset(connection, 0, sizeof *connection);
        connection->fd = fd;
        connection->update = update;
index 0be1c47..1e9f915 100644 (file)
@@ -394,7 +394,12 @@ wl_display_connect(const char *name)
        display->connection = wl_connection_create(display->fd,
                                                   connection_update,
                                                   display);
-
+       if (display->connection == NULL) {
+               wl_hash_table_destroy(display->objects);
+               close(display->fd);
+               free(display);
+               return NULL;
+       }
        return display;
 }
 
index 99b9f33..faa1e1a 100644 (file)
@@ -226,6 +226,10 @@ wl_client_create(struct wl_display *display, int fd)
                                              wl_client_connection_data, client);
        client->connection =
                wl_connection_create(fd, wl_client_connection_update, client);
+       if (client->connection == NULL) {
+               free(client);
+               return NULL;
+       }
 
        wl_list_init(&client->resource_list);