evas: fix a NULL dereference issue 86/59186/3
authorMinwoo, Lee <minwoo47.lee@samsung.com>
Wed, 6 Jan 2016 19:24:16 +0000 (11:24 -0800)
committerYoungbok Shin <youngb.shin@samsung.com>
Wed, 17 Feb 2016 08:22:47 +0000 (00:22 -0800)
Summary:
If evas engine init failed, it can make crash.
For example
If opengl init failed, then ee->prop.window is 0
ecore_evas_gl_x11_options_new_internal
{
   if (!ee->prop.window)
     {
        ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
        ecore_evas_free(ee);
        return NULL;
     }
}

ecore_evas_free calls evas_fonts_zero_pressure
and this time evas->engine.func is NULL so it makes crash.

Reviewers: cedric

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D3542

Change-Id: I1f1becdc34856fe75a6de7eafb76ec78bfc8ccba
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/evas/canvas/evas_font_dir.c

index ddac822..d357ce8 100644 (file)
@@ -148,7 +148,8 @@ evas_fonts_zero_free(Evas *eo_evas)
      {
         if (fd->fdesc) evas_font_desc_unref(fd->fdesc);
        if (fd->source) eina_stringshare_del(fd->source);
-       evas->engine.func->font_free(evas->engine.data.output, fd->font);
+       if ((evas->engine.func) && (evas->engine.func->font_free))
+         evas->engine.func->font_free(evas->engine.data.output, fd->font);
 #ifdef HAVE_FONTCONFIG
        if (fd->set) FcFontSetDestroy(fd->set);
        if (fd->p_nm) FcPatternDestroy(fd->p_nm);
@@ -173,7 +174,8 @@ evas_fonts_zero_pressure(Evas *eo_evas)
 
         if (fd->fdesc) evas_font_desc_unref(fd->fdesc);
        if (fd->source) eina_stringshare_del(fd->source);
-       evas->engine.func->font_free(evas->engine.data.output, fd->font);
+       if ((evas->engine.func) && (evas->engine.func->font_free))
+         evas->engine.func->font_free(evas->engine.data.output, fd->font);
 #ifdef HAVE_FONTCONFIG
        if (fd->set) FcFontSetDestroy(fd->set);
        if (fd->p_nm) FcPatternDestroy(fd->p_nm);