neuwld

patched neuwld library (tracked)
git clone https://git.daat.foo/neuwld.git
Log | Files | Refs | README | LICENSE

commit dfa8f7981b612fb7d827776b1810f504dd6add10
parent 2e0c4d7a7aa3ed9126a0d39d2eb29d3f0a13cd42
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 10 Jul 2019 21:11:04 -0700

pixman: Avoid VLA for glyph array

Diffstat:
MMakefile | 2+-
Mpixman.c | 8+++++++-
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -87,7 +87,7 @@ WLD_PACKAGES = $(WLD_REQUIRES) $(WLD_REQUIRES_PRIVATE) WLD_PACKAGE_CFLAGS ?= $(call pkgconfig,$(WLD_PACKAGES),cflags,CFLAGS) WLD_PACKAGE_LIBS ?= $(call pkgconfig,$(WLD_PACKAGES),libs,LIBS) -FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=c99 +FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=c99 -Wvla FINAL_CPPFLAGS = $(CPPFLAGS) -D_XOPEN_SOURCE=700 # Warning/error flags diff --git a/pixman.c b/pixman.c @@ -348,11 +348,16 @@ renderer_draw_text(struct wld_renderer *base, uint32_t c; struct glyph *glyph; FT_UInt glyph_index; - pixman_glyph_t glyphs[length == -1 ? (length = strlen(text)) : length]; + pixman_glyph_t *glyphs; uint32_t index = 0, origin_x = 0; pixman_color_t pixman_color = PIXMAN_COLOR(color); pixman_image_t *solid; + if (length == -1) + length = strlen(text); + glyphs = malloc(length * sizeof(glyphs[0])); + if (!glyphs) + return; solid = pixman_image_create_solid_fill(&pixman_color); while ((ret = FcUtf8ToUcs4((FcChar8 *)text, &c, length)) > 0 && c != '\0') { @@ -419,6 +424,7 @@ renderer_draw_text(struct wld_renderer *base, 0, 0, x, y, renderer->glyph_cache, index, glyphs); + free(glyphs); pixman_image_unref(solid); if (extents)