derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=05d7c1c9a2e793b1051eb889e0c5173512338bb1

commit 05d7c1c9a2e793b1051eb889e0c5173512338bb1
Author: Derek Foreman <[email protected]>
Date:   Thu Mar 8 13:46:42 2018 -0600

    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.
---
 .../evas/engines/gl_common/evas_gl_context.c       | 26 +++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

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)
    ERR("GL symbols missing!");
 }
 
+/* This check is based heavily on the check from libepoxy.
+ * Previously we used strstr(), however there are some extensions
+ * whose names are subsets of others.
+ */
 EAPI Eina_Bool
 evas_gl_extension_string_check(const char *exts, const char *ext)
 {
+   const char *ptr;
+   int len;
+
    if (!exts || !ext) return EINA_FALSE;
-   return strstr(exts, ext) != NULL;
+   ptr = exts;
+
+   if (*ptr == '\0')
+     return EINA_FALSE;
+
+   len = strlen(ext);
+
+   while (1)
+     {
+        ptr = strstr(ptr, ext);
+        if (!ptr)
+          return EINA_FALSE;
+
+        if (ptr[len] == ' ' || ptr[len] == '\0')
+          return EINA_TRUE;
+
+        ptr += len;
+     }
 }
 
 /* Totally gross, but I didn't want to reindent all the

-- 


Reply via email to