From ccbca43457cfe7b492a220845ad975abe8cf53ba Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 4 Dec 2011 20:06:53 +0000 Subject: Avoid memory leak when requested font cannot be opened. svn path=/trunk/netsurf/; revision=13243 --- amiga/font.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/amiga/font.c b/amiga/font.c index 3bc72e1eb..7c45049b0 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -334,14 +334,8 @@ struct ami_font_node *ami_font_open(const char *font) LOG(("Font cache miss: %s", font)); nodedata = AllocVec(sizeof(struct ami_font_node), MEMF_PRIVATE | MEMF_CLEAR); - - node = AddObject(ami_font_list, AMINS_FONT); - if(!node) return NULL; - - node->objstruct = nodedata; - node->dtz_Node.ln_Name = strdup(font); - nodedata->font = OpenOutlineFont(font, &ami_diskfontlib_list, OFF_OPEN); + if(!nodedata->font) { LOG(("Requested font not found: %s", font)); @@ -369,6 +363,13 @@ struct ami_font_node *ami_font_open(const char *font) GetSysTime(&nodedata->lastused); + node = AddObject(ami_font_list, AMINS_FONT); + if(node) + { + node->objstruct = nodedata; + node->dtz_Node.ln_Name = strdup(font); + } + return nodedata; } -- cgit v1.2.3