ecore-evas-wayland: Fix use after free

Coverity reports illegal access here as we are trying to pass a freed
pointer to ecore_evas_free. Rework error handling to avoid this.

Fixes Coverity CID1365657

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2016-11-08 11:06:36 -05:00
parent 867cf1564a
commit 90dabc831f
1 changed files with 11 additions and 8 deletions

View File

@ -2028,23 +2028,23 @@ _ecore_evas_wl_common_new_internal(const char *disp_name, unsigned int parent, i
} }
ewd = ecore_wl2_display_connect(disp_name); ewd = ecore_wl2_display_connect(disp_name);
if (!ewd) if (!ewd)
{ {
ERR("Failed to connect to Wayland Display %s", disp_name); ERR("Failed to connect to Wayland Display %s", disp_name);
goto conn_err; goto conn_err;
} }
if (!(ee = calloc(1, sizeof(Ecore_Evas)))) if (!(ee = calloc(1, sizeof(Ecore_Evas))))
{ {
ERR("Failed to allocate Ecore_Evas"); ERR("Failed to allocate Ecore_Evas");
goto err; goto ee_err;
} }
if (!(wdata = calloc(1, sizeof(Ecore_Evas_Engine_Wl_Data)))) if (!(wdata = calloc(1, sizeof(Ecore_Evas_Engine_Wl_Data))))
{ {
ERR("Failed to allocate Ecore_Evas_Engine_Wl_Data"); ERR("Failed to allocate Ecore_Evas_Engine_Wl_Data");
free(ee); free(ee);
goto err; goto werr;
} }
if (frame) WRN("draw_frame is now deprecated and will have no effect"); if (frame) WRN("draw_frame is now deprecated and will have no effect");
@ -2132,13 +2132,13 @@ _ecore_evas_wl_common_new_internal(const char *disp_name, unsigned int parent, i
if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
{ {
ERR("Failed to set Evas Engine Info for '%s'", ee->driver); ERR("Failed to set Evas Engine Info for '%s'", ee->driver);
goto err; goto eng_err;
} }
} }
else else
{ {
ERR("Failed to get Evas Engine Info for '%s'", ee->driver); ERR("Failed to get Evas Engine Info for '%s'", ee->driver);
goto err; goto eng_err;
} }
} }
@ -2162,9 +2162,12 @@ _ecore_evas_wl_common_new_internal(const char *disp_name, unsigned int parent, i
return ee; return ee;
err: eng_err:
if (ee) ecore_evas_free(ee); ecore_evas_free(ee);
else ecore_wl2_display_disconnect(ewd); w_err:
free(ee);
ee_err:
ecore_wl2_display_disconnect(ewd);
conn_err: conn_err:
ecore_wl2_shutdown(); ecore_wl2_shutdown();
return NULL; return NULL;