From 55a04881d8c715ff5c280fb0b3b5a9003833c521 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 6 Feb 2011 08:46:48 -0800 Subject: [PATCH] Fixed crash when binary shaders are not available. --- src/render/opengles2/SDL_render_gles2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 8de996435..7687a531d 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -558,16 +558,17 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b } /* Find a matching shader instance that's supported on this hardware */ - for (i = 0; i < shader->instance_count; ++i) + for (i = 0; i < shader->instance_count && !instance; ++i) { - for (j = 0; j < rdata->shader_format_count; ++j) + for (j = 0; j < rdata->shader_format_count && !instance; ++j) { if (!shader->instances) continue; + if (!shader->instances[i]) + continue; if (shader->instances[i]->format != rdata->shader_formats[j]) continue; instance = shader->instances[i]; - break; } } if (!instance)