Commit 8ab698af15f7d8ae91a750bf5c7b219381ff3587

Ryan C. Gordon 2019-03-21T10:39:49

opengles2: Fix static analysis warning. Not clear if this could ever dereference NULL in real life, but better safe than sorry!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index b77779d..028227f 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -529,8 +529,10 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLES2_ShaderCacheEntry *vertex,
         }
         data->glDeleteProgram(data->program_cache.tail->id);
         data->program_cache.tail = data->program_cache.tail->prev;
-        SDL_free(data->program_cache.tail->next);
-        data->program_cache.tail->next = NULL;
+        if (data->program_cache.tail != NULL) {
+            SDL_free(data->program_cache.tail->next);
+            data->program_cache.tail->next = NULL;
+        }
         --data->program_cache.count;
     }
     return entry;