Commit 3bdc79d0eef2496bf37da5d8bd891546745f8522

Thomas de Grivel 2024-02-27T08:33:40

uninitialized use

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/libc3/window/sdl2/gl_vtext.c b/libc3/window/sdl2/gl_vtext.c
index b12ec93..5371f80 100644
--- a/libc3/window/sdl2/gl_vtext.c
+++ b/libc3/window/sdl2/gl_vtext.c
@@ -246,6 +246,7 @@ bool gl_vtext_render_to_texture_random (s_gl_text *text, uw len)
     return false;
   }
   for (i = 0; i < (sw) len; i++) {
+    glyph = NULL;
     do {
       u32_random_uniform(glyphs + i, face->num_glyphs - 2);
       glyphs[i]++;
@@ -253,7 +254,7 @@ bool gl_vtext_render_to_texture_random (s_gl_text *text, uw len)
         continue;
       glyph = face->glyph;
       //printf("width %ld\n", glyph->metrics.width >> 6);
-    } while (! (glyph->metrics.width >> 6));
+    } while (! glyph || ! (glyph->metrics.width >> 6));
   }
   scale_y = face->size->metrics.y_scale / 65536.0;
   max_ascent = (u32) (face->ascender * scale_y) >> 6;