e_pixmap: ref/unref wl_shm_pool for safe accessing shm buffer data 57/69157/2
authorMinJeong Kim <minjjj.kim@samsung.com>
Thu, 12 May 2016 04:21:07 +0000 (13:21 +0900)
committerMinJeong Kim <minjjj.kim@samsung.com>
Thu, 12 May 2016 05:00:51 +0000 (14:00 +0900)
To manage unmapping of shm buffer pool only inside of wayland-shm
implementation is totally unsafe because there are some cases that the wayland
display server handles data of some shm buffer after destroying of a wayland
client which wass wrtier of the shm buffer. So ref/unref APIs of wl_shm_pool
are necessary to use buffer without risk.

Change-Id: I7ae9251a9755ebad97afb8d6fd8e2d7f05fa9a22

src/bin/e_pixmap.c

index 343cb7adb65edbd012618be66cdd7e7d4835a80c..de1e897e9f225a913557b7434e5901492728e1fe 100644 (file)
@@ -34,6 +34,7 @@ struct _E_Pixmap
    E_Comp_Wl_Buffer_Ref buffer_ref;
    struct wl_listener buffer_destroy_listener;
    void *data;
+   struct wl_shm_pool *data_pool;
    Eina_Rectangle opaque;
    uuid_t uuid;
 
@@ -116,6 +117,11 @@ _e_pixmap_free(E_Pixmap *cp)
         E_FREE(cp->cdata);
         cp->own_cdata = EINA_FALSE;
      }
+   if (cp->data_pool)
+     {
+        wl_shm_pool_unref(cp->data_pool);
+        cp->data_pool = NULL;
+     }
    _e_pixmap_clear(cp, 1);
    ELOG("PIXMAP FREE", cp, cp->client);
    free(cp);
@@ -631,6 +637,9 @@ e_pixmap_image_refresh(E_Pixmap *cp)
           }
 
         cp->data = wl_shm_buffer_get_data(shm_buffer);
+
+        if (cp->data_pool) wl_shm_pool_unref(cp->data_pool);
+        cp->data_pool = wl_shm_buffer_ref_pool(shm_buffer);
      }
    else if (buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE)
      {