Fixed double-free in the shader cache at shutdown
authorSam Lantinga <slouken@libsdl.org>
Mon, 07 Nov 2011 00:45:13 -0500
changeset 6052263ef1203b76
parent 6051 cb1f941ce38e
child 6053 4d7b69e575f9
Fixed double-free in the shader cache at shutdown
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Sun Nov 06 17:05:48 2011 -0500
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Mon Nov 07 00:45:13 2011 -0500
     1.3 @@ -190,24 +190,34 @@
     1.4  GLES2_DestroyRenderer(SDL_Renderer *renderer)
     1.5  {
     1.6      GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
     1.7 -    GLES2_ProgramCacheEntry *entry;
     1.8 -    GLES2_ProgramCacheEntry *next;
     1.9  
    1.10      /* Deallocate everything */
    1.11      if (rdata) {
    1.12          GLES2_ActivateRenderer(renderer);
    1.13  
    1.14 -        entry = rdata->program_cache.head;
    1.15 -        while (entry) {
    1.16 -            glDeleteShader(entry->vertex_shader->id);
    1.17 -            glDeleteShader(entry->fragment_shader->id);
    1.18 -            SDL_free(entry->vertex_shader);
    1.19 -            SDL_free(entry->fragment_shader);
    1.20 -            glDeleteProgram(entry->id);
    1.21 -            next = entry->next;
    1.22 -            SDL_free(entry);
    1.23 -            entry = next;
    1.24 -        }
    1.25 +	{
    1.26 +	    GLES2_ShaderCacheEntry *entry;
    1.27 +	    GLES2_ShaderCacheEntry *next;
    1.28 +	    entry = rdata->shader_cache.head;
    1.29 +	    while (entry)
    1.30 +	    {
    1.31 +                glDeleteShader(entry->id);
    1.32 +                next = entry->next;
    1.33 +                SDL_free(entry);
    1.34 +                entry = next;
    1.35 +	    }
    1.36 +	}
    1.37 +	{
    1.38 +	    GLES2_ProgramCacheEntry *entry;
    1.39 +	    GLES2_ProgramCacheEntry *next;
    1.40 +            entry = rdata->program_cache.head;
    1.41 +            while (entry) {
    1.42 +                glDeleteProgram(entry->id);
    1.43 +                next = entry->next;
    1.44 +                SDL_free(entry);
    1.45 +                entry = next;
    1.46 +            }
    1.47 +	}
    1.48          if (rdata->context) {
    1.49              SDL_GL_DeleteContext(rdata->context);
    1.50          }