weston-ivi-shell: fix a memory leak of surface and resource.
authorNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
Mon, 4 Aug 2014 06:52:13 +0000 (15:52 +0900)
committerNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
Thu, 21 Aug 2014 01:08:14 +0000 (10:08 +0900)
Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
weston-ivi-shell/src/ivi-controller.c

index 434fc4b..d781f2d 100755 (executable)
@@ -1280,6 +1280,11 @@ controller_surface_create(struct wl_client *client,
     struct ivisurface *ivisurf = NULL;
     struct ivicontroller_surface *ctrl_link = NULL;
 
+    ivisurf = get_surface(&shell->list_surface, id_surface);
+    if (ivisurf == NULL) {
+        return;
+    }
+
     ctrlsurf = calloc(1, sizeof *ctrlsurf);
     if (!ctrlsurf) {
         weston_log("no memory to allocate controller surface\n");
@@ -1300,11 +1305,6 @@ controller_surface_create(struct wl_client *client,
         return;
     }
 
-    ivisurf = get_surface(&shell->list_surface, id_surface);
-    if (ivisurf == NULL) {
-        return;
-    }
-
     wl_list_for_each(ctrl_link, &shell->list_controller_surface, link) {
         if ((ctrl_link->implementation_set == 0) &&
             (ctrl_link->id_surface == id_surface) &&