tdm: check if null before using allocated memory. 66/68866/1
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 10 May 2016 06:48:57 +0000 (15:48 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Tue, 10 May 2016 06:57:05 +0000 (15:57 +0900)
Change-Id: I2708e7bc43decff58065a35dcb6b6445505699a4

src/lib/tdm/tdm-common.c

index 9cce721..b31e8f9 100644 (file)
@@ -48,9 +48,9 @@ pepper_tdm_create(pepper_compositor_t *compositor)
        struct wl_event_loop   *loop;
 
        tdm = calloc(1, sizeof(pepper_tdm_t));
-       tdm->fd = -1;
-       PEPPER_CHECK(tdm, goto error, "calloc() failed.\n");
+       PEPPER_CHECK(tdm, return NULL, "calloc() failed.\n");
 
+       tdm->fd = -1;
        tdm->compositor = compositor;
        tdm->disp = tdm_display_init(&ret);
        PEPPER_CHECK(ret == TDM_ERROR_NONE, goto error,
@@ -90,8 +90,7 @@ pepper_tdm_create(pepper_compositor_t *compositor)
        return tdm;
 
 error:
-       if (tdm)
-               pepper_tdm_destroy(tdm);
+       pepper_tdm_destroy(tdm);
 
        return NULL;
 }