server: Fix shm_create_pool size fail path fd leak
authorSergi Granell <xerpi.g.12@gmail.com>
Thu, 18 Feb 2016 22:59:29 +0000 (23:59 +0100)
committerBryce Harrington <bryce@osg.samsung.com>
Wed, 9 Mar 2016 00:37:20 +0000 (16:37 -0800)
commit5fe7e7ca78eb8c5435f35ed47b54aabdbdcaadf7
treea35e17096f0d40a58b5a5866e39bbb9ce32c8d84
parentba2ee84113e7f9fef9af2ec3998ee437adab5382
server: Fix shm_create_pool size fail path fd leak

If the client passed a size <= 0 to shm_create_pool, it would
go to err_free, which wouldn't close the fd, and thus leave it opened.

We can also move the size check before the struct wl_shm_pool
malloc, so in case the client passes a wrong size, it won't
do an unnecessary malloc and then free.
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
src/wayland-shm.c