mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
server: Fix possible wl_display_add_socket_fd memleak
If wl_event_loop_add_fd failed, the fail path didn't free the newly allocated struct wl_socket. Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
This commit is contained in:
parent
14b76a0e24
commit
ac36082813
1 changed files with 5 additions and 4 deletions
|
|
@ -1268,17 +1268,18 @@ wl_display_add_socket_fd(struct wl_display *display, int sock_fd)
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Reuse the existing fd */
|
s->source = wl_event_loop_add_fd(display->loop, sock_fd,
|
||||||
s->fd = sock_fd;
|
|
||||||
|
|
||||||
s->source = wl_event_loop_add_fd(display->loop, s->fd,
|
|
||||||
WL_EVENT_READABLE,
|
WL_EVENT_READABLE,
|
||||||
socket_data, display);
|
socket_data, display);
|
||||||
if (s->source == NULL) {
|
if (s->source == NULL) {
|
||||||
wl_log("failed to establish event source\n");
|
wl_log("failed to establish event source\n");
|
||||||
|
wl_socket_destroy(s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reuse the existing fd */
|
||||||
|
s->fd = sock_fd;
|
||||||
|
|
||||||
wl_list_insert(display->socket_list.prev, &s->link);
|
wl_list_insert(display->socket_list.prev, &s->link);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue