evas: Gl_Cocoa - fix early segfault caused by unloaded symbols
authorJean Guyomarc'h <jean.guyomarch@gmail.com>
Mon, 22 Sep 2014 12:20:31 +0000 (14:20 +0200)
committerCedric BAIL <cedric@osg.samsung.com>
Mon, 22 Sep 2014 12:59:27 +0000 (14:59 +0200)
Summary:
evas_gl_symbols() (introduced in commit 9a9d78d) was not dlsym()ed
which led to unloaded symbols, so NULL function pointers which were happily
dereferenced, leading to an early segfault, and therefore to a broken engine.

@fix

Reviewers: cedric, raoulh

Subscribers: cedric

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

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/modules/evas/engines/gl_cocoa/evas_engine.c

index 1a1eb9b..76bc6d5 100644 (file)
@@ -13,6 +13,8 @@ typedef struct _Render_Engine Render_Engine;
 typedef struct _Render_Engine_GL_Surface    Render_Engine_GL_Surface;
 typedef struct _Render_Engine_GL_Context    Render_Engine_GL_Context;
 
+Evas_Gl_Symbols glsym_evas_gl_symbols = NULL;
+
 struct _Render_Engine
 {
    Evas_GL_Cocoa_Window *win;
@@ -1337,6 +1339,12 @@ eng_image_load_error_get(void *data EINA_UNUSED, void *image)
    return im->im->cache_entry.load_error;
 }
 
+static void *
+_dlsym(const char *sym)
+{
+   return dlsym(RTLD_DEFAULT, sym);
+}
+
 static int
 module_open(Evas_Module *em)
 {
@@ -1422,6 +1430,12 @@ module_open(Evas_Module *em)
 
    ORD(image_load_error_get);    
 
+#define LINK2GENERIC(sym) \
+   glsym_##sym = dlsym(RTLD_DEFAULT, #sym);
+
+   LINK2GENERIC(evas_gl_symbols);
+   glsym_evas_gl_symbols(_dlsym);
+
    /* now advertise out own api */
    em->functions = (void *)(&func);
    return 1;