summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2018-03-08 13:46:42 -0600
committerDerek Foreman <derekf@osg.samsung.com>2018-03-08 14:27:07 -0600
commit05d7c1c9a2e793b1051eb889e0c5173512338bb1 (patch)
tree9d199f7ba9d97ce798a2ae06d52e82220e1102a4 /src/modules/evas/engines
parent464d0ca9bb1146b48d42d8145245e93760bec9e8 (diff)
gl_common: Make extension string checks more robust
strstr() can give false positives if the extension name is a subset of a string in the extension list, for example EGL_EXT_image_dma_buf_import would match EGL_EXT_image_dma_buf_import_modifiers. I've opted for a mildly badgered copy of epoxy's test, which should be robust in the face of subsets.
Diffstat (limited to 'src/modules/evas/engines')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c
index 8294963dd1..b010057c2a 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -84,11 +84,35 @@ sym_missing(void)
84 ERR("GL symbols missing!"); 84 ERR("GL symbols missing!");
85} 85}
86 86
87/* This check is based heavily on the check from libepoxy.
88 * Previously we used strstr(), however there are some extensions
89 * whose names are subsets of others.
90 */
87EAPI Eina_Bool 91EAPI Eina_Bool
88evas_gl_extension_string_check(const char *exts, const char *ext) 92evas_gl_extension_string_check(const char *exts, const char *ext)
89{ 93{
94 const char *ptr;
95 int len;
96
90 if (!exts || !ext) return EINA_FALSE; 97 if (!exts || !ext) return EINA_FALSE;
91 return strstr(exts, ext) != NULL; 98 ptr = exts;
99
100 if (*ptr == '\0')
101 return EINA_FALSE;
102
103 len = strlen(ext);
104
105 while (1)
106 {
107 ptr = strstr(ptr, ext);
108 if (!ptr)
109 return EINA_FALSE;
110
111 if (ptr[len] == ' ' || ptr[len] == '\0')
112 return EINA_TRUE;
113
114 ptr += len;
115 }
92} 116}
93 117
94/* Totally gross, but I didn't want to reindent all the 118/* Totally gross, but I didn't want to reindent all the