commit dfa8f79
Michael Forney
·
2019-07-11 04:11:04 +0000 UTC
parent 2e0c4d7
pixman: Avoid VLA for glyph array
M
Makefile
+1,
-1
1@@ -87,7 +87,7 @@ WLD_PACKAGES = $(WLD_REQUIRES) $(WLD_REQUIRES_PRIVATE)
2 WLD_PACKAGE_CFLAGS ?= $(call pkgconfig,$(WLD_PACKAGES),cflags,CFLAGS)
3 WLD_PACKAGE_LIBS ?= $(call pkgconfig,$(WLD_PACKAGES),libs,LIBS)
4
5-FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=c99
6+FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=c99 -Wvla
7 FINAL_CPPFLAGS = $(CPPFLAGS) -D_XOPEN_SOURCE=700
8
9 # Warning/error flags
M
pixman.c
+7,
-1
1@@ -348,11 +348,16 @@ renderer_draw_text(struct wld_renderer *base,
2 uint32_t c;
3 struct glyph *glyph;
4 FT_UInt glyph_index;
5- pixman_glyph_t glyphs[length == -1 ? (length = strlen(text)) : length];
6+ pixman_glyph_t *glyphs;
7 uint32_t index = 0, origin_x = 0;
8 pixman_color_t pixman_color = PIXMAN_COLOR(color);
9 pixman_image_t *solid;
10
11+ if (length == -1)
12+ length = strlen(text);
13+ glyphs = malloc(length * sizeof(glyphs[0]));
14+ if (!glyphs)
15+ return;
16 solid = pixman_image_create_solid_fill(&pixman_color);
17
18 while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length)) > 0 && c != '\0') {
19@@ -419,6 +424,7 @@ renderer_draw_text(struct wld_renderer *base,
20 0, 0, x, y, renderer->glyph_cache,
21 index, glyphs);
22
23+ free(glyphs);
24 pixman_image_unref(solid);
25
26 if (extents)