From 750677795ba1ca41627edd68a4de24e0d6c07a20 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Wed, 20 Jan 2016 22:51:05 +0000 Subject: Alloc font name on the stack --- amiga/font_diskfont.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'amiga') diff --git a/amiga/font_diskfont.c b/amiga/font_diskfont.c index 7b8819969..bd1e1f9d0 100644 --- a/amiga/font_diskfont.c +++ b/amiga/font_diskfont.c @@ -35,11 +35,14 @@ #include "amiga/gui.h" #include "amiga/utf8.h" +#define MAX_FONT_NAME_SIZE 33 + static struct TextFont *ami_font_bm_open(struct RastPort *rp, const plot_font_style_t *fstyle) { struct TextFont *bmfont = NULL; struct TextAttr tattr; - char *fontname, *font; + char *fontname; + char font[MAX_FONT_NAME_SIZE]; if(rp == NULL) return NULL; @@ -78,14 +81,12 @@ static struct TextFont *ami_font_bm_open(struct RastPort *rp, const plot_font_st if (fstyle->weight >= 700) tattr.ta_Style |= FSF_BOLD; - if((font = ASPrintf("%s.font", fontname))) { - tattr.ta_Name = font; - tattr.ta_YSize = fstyle->size / FONT_SIZE_SCALE; - LOG("font: %s/%d", tattr.ta_Name, tattr.ta_YSize); - if((bmfont = OpenDiskFont(&tattr))) { - SetRPAttrs(rp, RPTAG_Font, bmfont, TAG_DONE); - } - FreeVec(font); + snprintf(font, MAX_FONT_NAME_SIZE, "%s.font", fontname); + tattr.ta_Name = font; + tattr.ta_YSize = fstyle->size / FONT_SIZE_SCALE; + LOG("font: %s/%d", tattr.ta_Name, tattr.ta_YSize); + if((bmfont = OpenDiskFont(&tattr))) { + SetRPAttrs(rp, RPTAG_Font, bmfont, TAG_DONE); } return bmfont; -- cgit v1.2.3