Added wl_connection_create failure checks.

This commit is contained in:
Iskren Chernev 2011-03-11 14:43:10 +02:00 committed by Kristian Høgsberg
parent fcd4caa0df
commit ecbad0341e
3 changed files with 12 additions and 1 deletions

View file

@ -160,6 +160,8 @@ wl_connection_create(int fd,
struct wl_connection *connection; struct wl_connection *connection;
connection = malloc(sizeof *connection); connection = malloc(sizeof *connection);
if (connection == NULL)
return NULL;
memset(connection, 0, sizeof *connection); memset(connection, 0, sizeof *connection);
connection->fd = fd; connection->fd = fd;
connection->update = update; connection->update = update;

View file

@ -394,7 +394,12 @@ wl_display_connect(const char *name)
display->connection = wl_connection_create(display->fd, display->connection = wl_connection_create(display->fd,
connection_update, connection_update,
display); display);
if (display->connection == NULL) {
wl_hash_table_destroy(display->objects);
close(display->fd);
free(display);
return NULL;
}
return display; return display;
} }

View file

@ -226,6 +226,10 @@ wl_client_create(struct wl_display *display, int fd)
wl_client_connection_data, client); wl_client_connection_data, client);
client->connection = client->connection =
wl_connection_create(fd, wl_client_connection_update, client); wl_connection_create(fd, wl_client_connection_update, client);
if (client->connection == NULL) {
free(client);
return NULL;
}
wl_list_init(&client->resource_list); wl_list_init(&client->resource_list);