From 4b832e8917ef2fd224914e10d287f30ea3cc0bff Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 17 Apr 2022 10:06:08 +0200 Subject: [PATCH] drw_text: don't segfault when called with 0 width this patch just rejects *any* 0 width draws, which is surely an error by the caller. this also guards against cases where the width is too small for the ellipsis to fit, so ellipsis_w will remain 0. reported by Bakkeby ref. https://git.suckless.org/dmenu/commit/e4827b0c4048718ab06670cf60ef68d028fe7fc4.html --- drw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drw.c b/drw.c index a9c23cd..a9c2916 100644 --- a/drw.c +++ b/drw.c @@ -448,7 +448,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp const char *ellipsis = "..."; static unsigned int ellipsis_width = 0; - if (!drw || (render && !drw->scheme) || !text || !drw->fonts) + if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts) return 0; if (!render) {