yagl_glsl_state: Early exit on cleanup when Shader was not initialized 73/262673/1 accepted/tizen/unified/20210820.101815 submit/tizen/20210818.223105
authorLukasz Kostyra <l.kostyra@samsung.com>
Tue, 17 Aug 2021 11:26:08 +0000 (13:26 +0200)
committerLukasz Kostyra <l.kostyra@samsung.com>
Tue, 17 Aug 2021 11:29:10 +0000 (13:29 +0200)
There might be situations like:
  glCreateShader(shader, ...);
  glDestroyShader(shader);

This would crash since yagl_glsl_state is initialized only when
glShaderSource() is called. Situation is now fixed.

This fixes gl-getshadersource WebGL browser test.

Change-Id: Icd8fa28bc1866f4f6cd3f199fb5a8ad724d71573
Signed-off-by: Lukasz Kostyra <l.kostyra@samsung.com>
GLESv2/yagl_glsl_lexer.l

index c0515726834c3c9076ec279623724490b3236bc0..f71fb0338e8d2c3f97ccf774bf358fe8a10ef11b 100644 (file)
@@ -672,6 +672,11 @@ void yagl_glsl_state_cleanup(struct yagl_glsl_state *state)
     struct yagl_glsl_sampler *sampler_tmp;
     struct yagl_glsl_define *defines_tmp;
 
+    if (state->shader_type == 0) {
+        // yagl_glsl_state_init was not called, quietly exit
+        return;
+    }
+
     tmp = yagl_vector_data(&state->strings);
 
     for (i = 0; i < yagl_vector_size(&state->strings); ++i) {