From 5b9b715cc48647b09594268f3979e6c8ebf58013 Mon Sep 17 00:00:00 2001 From: kojima Date: Sun, 19 Sep 1999 01:30:13 +0000 Subject: [PATCH] default system font string (which is readonly) overwrite bug fix --- WINGs/wfont.c | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/WINGs/wfont.c b/WINGs/wfont.c index a2465b4c..68b803c7 100644 --- a/WINGs/wfont.c +++ b/WINGs/wfont.c @@ -317,31 +317,41 @@ WMDrawImageString(WMScreen *scr, Drawable d, GC gc, WMFont *font, int x, int y, static char* makeFontSetOfSize(char *fontset, int size) { - char font[300]; + char font[300], *f; char *newfs = NULL; char *ptr; - char *tmp; do { - int hold = ' '; - + char *tmp; + int end; + + + f = fontset; ptr = strchr(fontset, ','); if (ptr) { - hold = *(ptr+1); - *(ptr+1) = 0; - } - if (strlen(fontset)>255) { - wwarning("font description %s is too large.", fontset); - } else { - sprintf(font, fontset, size); - tmp = wstrappend(newfs, font); - if (newfs) - free(newfs); - newfs = tmp; - } - if (ptr) { - *(ptr+1) = hold; + int count = ptr-fontset; + + if (count > 255) { + wwarning("font description %s is too large.", fontset); + } else { + memcpy(font, fontset, count); + font[count] = 0; + f = (char*)font; + } } + + if (newfs) + end = strlen(newfs); + else + end = 0; + + tmp = wmalloc(end + strlen(f) + 8); + sprintf(tmp + end, f, size); + + if (newfs) + free(newfs); + newfs = tmp; + fontset = ptr+1; } while (ptr!=NULL);