From ea5839c8fef1fbaee8a8a5a6389f35dd537dccfc Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Tue, 20 May 2014 01:37:58 -0700 Subject: [PATCH 1/2] glapi: Avoid heap corruption in _glapi_table Signed-off-by: Jeremy Huddleston Sequoia Reviewed-by: Chia-I Wu (cherry picked from commit ff5456d1acf6f627a6837be3f3f37c6a268c9e8e) --- src/mapi/glapi/gen/gl_gentable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mapi/glapi/gen/gl_gentable.py b/src/mapi/glapi/gen/gl_gentable.py index 35dddc7a088..d45a5e0ffc3 100644 --- a/src/mapi/glapi/gen/gl_gentable.py +++ b/src/mapi/glapi/gen/gl_gentable.py @@ -113,7 +113,7 @@ __glapi_gentable_set_remaining_noop(struct _glapi_table *disp) { struct _glapi_table * _glapi_create_table_from_handle(void *handle, const char *symbol_prefix) { - struct _glapi_table *disp = calloc(1, sizeof(struct _glapi_table)); + struct _glapi_table *disp = calloc(1, _glapi_get_dispatch_table_size() * sizeof(_glapi_proc)); char symboln[512]; if(!disp) From ec83a39e2b950982307825cbb64fbbe3c2934838 Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Tue, 20 May 2014 10:53:00 -0700 Subject: [PATCH 2/2] darwin: Fix test for kCGLPFAOpenGLProfile support at runtime Signed-off-by: Jeremy Huddleston Sequoia (cherry picked from commit 7a109268ab5b3544e7f7b99e84ef1fdf54023fb4) --- src/glx/apple/apple_visual.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/glx/apple/apple_visual.c b/src/glx/apple/apple_visual.c index 282934f1749..238c24881c9 100644 --- a/src/glx/apple/apple_visual.c +++ b/src/glx/apple/apple_visual.c @@ -73,11 +73,15 @@ apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const struct glx_config * m GLint vsref = 0; CGLError error = 0; - /* Request an OpenGL 3.2 profile if one is available */ - if(apple_cgl.version_major > 1 || (apple_cgl.version_major == 1 && apple_cgl.version_minor >= 3)) { - attr[numattr++] = kCGLPFAOpenGLProfile; - attr[numattr++] = kCGLOGLPVersion_3_2_Core; - } + /* Request an OpenGL 3.2 profile if one is available and supported */ + attr[numattr++] = kCGLPFAOpenGLProfile; + attr[numattr++] = kCGLOGLPVersion_3_2_Core; + + /* Test for kCGLPFAOpenGLProfile support at runtime and roll it out if not supported */ + attr[numattr] = 0; + error = apple_cgl.choose_pixel_format(attr, pfobj, &vsref); + if (error == kCGLBadAttribute) + numattr -= 2; if (offscreen) { apple_glx_diagnostic