Fixed double-free in the shader cache at shutdown
authorSam Lantinga <slouken@libsdl.org>
Mon, 07 Nov 2011 00:45:13 -0500
changeset 6052 263ef1203b76
parent 6051 cb1f941ce38e
child 6053 4d7b69e575f9
Fixed double-free in the shader cache at shutdown
src/render/opengles2/SDL_render_gles2.c
--- a/src/render/opengles2/SDL_render_gles2.c	Sun Nov 06 17:05:48 2011 -0500
+++ b/src/render/opengles2/SDL_render_gles2.c	Mon Nov 07 00:45:13 2011 -0500
@@ -190,24 +190,34 @@
 GLES2_DestroyRenderer(SDL_Renderer *renderer)
 {
     GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
-    GLES2_ProgramCacheEntry *entry;
-    GLES2_ProgramCacheEntry *next;
 
     /* Deallocate everything */
     if (rdata) {
         GLES2_ActivateRenderer(renderer);
 
-        entry = rdata->program_cache.head;
-        while (entry) {
-            glDeleteShader(entry->vertex_shader->id);
-            glDeleteShader(entry->fragment_shader->id);
-            SDL_free(entry->vertex_shader);
-            SDL_free(entry->fragment_shader);
-            glDeleteProgram(entry->id);
-            next = entry->next;
-            SDL_free(entry);
-            entry = next;
-        }
+	{
+	    GLES2_ShaderCacheEntry *entry;
+	    GLES2_ShaderCacheEntry *next;
+	    entry = rdata->shader_cache.head;
+	    while (entry)
+	    {
+                glDeleteShader(entry->id);
+                next = entry->next;
+                SDL_free(entry);
+                entry = next;
+	    }
+	}
+	{
+	    GLES2_ProgramCacheEntry *entry;
+	    GLES2_ProgramCacheEntry *next;
+            entry = rdata->program_cache.head;
+            while (entry) {
+                glDeleteProgram(entry->id);
+                next = entry->next;
+                SDL_free(entry);
+                entry = next;
+            }
+	}
         if (rdata->context) {
             SDL_GL_DeleteContext(rdata->context);
         }