From 469066a924e0e3814ba5ffcf40d9cd46cb3eb7fc Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 17 Nov 2016 21:23:49 -0500 Subject: [PATCH] Fixed an issue with drawing non ascii runes causing infinite loop --- inc/stdc.h | 3 +++ xedit.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/stdc.h b/inc/stdc.h index 29b8947..cbbcd57 100644 --- a/inc/stdc.h +++ b/inc/stdc.h @@ -147,6 +147,9 @@ static inline char* _getopt_(int* p_argc, char*** p_argv) { /* Error Handling *****************************************************************************/ +#define trace() \ + fprintf(stderr, "%s:%d\n", __FILE__, __LINE__) + #ifdef NDEBUG #define debug(msg, ...) \ ((void)0) diff --git a/xedit.c b/xedit.c index 44ded47..7473fb1 100644 --- a/xedit.c +++ b/xedit.c @@ -291,7 +291,7 @@ static void draw_runes(size_t x, size_t y, int fg, int bg, UGlyph* glyphs, size_ static void draw_glyphs(size_t x, size_t y, UGlyph* glyphs, size_t rlen, size_t ncols) { XGlyphSpec specs[rlen]; size_t i = 0; - while (rlen) { + while (rlen && i < ncols) { int numspecs = 0; uint32_t attr = glyphs[i].attr; while (i < ncols && glyphs[i].attr == attr) { -- 2.52.0