screen-share: fix possible memory leak for `out_pixman_error` case

shm buffer should be freed in case of `out_pixman_error`, and should
be inserted into shared_output just before the success return.

Signed-off-by: xndcn <xndchn@gmail.com>
dev
xndcn 4 years ago
parent ed4a0e9275
commit ffe422116d
  1. 4
      compositor/screen-share.c

@ -485,7 +485,6 @@ shared_output_get_shm_buffer(struct shared_output *so)
sb->output = so; sb->output = so;
wl_list_init(&sb->free_link); wl_list_init(&sb->free_link);
wl_list_insert(&so->shm.buffers, &sb->link);
pixman_region32_init_rect(&sb->damage, 0, 0, width, height); pixman_region32_init_rect(&sb->damage, 0, 0, width, height);
@ -510,10 +509,13 @@ shared_output_get_shm_buffer(struct shared_output *so)
if (!sb->pm_image) if (!sb->pm_image)
goto out_pixman_error; goto out_pixman_error;
wl_list_insert(&so->shm.buffers, &sb->link);
return sb; return sb;
out_pixman_error: out_pixman_error:
wl_buffer_destroy(sb->buffer);
pixman_region32_fini(&sb->damage); pixman_region32_fini(&sb->damage);
free(sb);
out_unmap: out_unmap:
munmap(data, height * stride); munmap(data, height * stride);
out_close: out_close:

Loading…
Cancel
Save