Avoid memory leak when requested font cannot be opened.

svn path=/trunk/netsurf/; revision=13243
This commit is contained in:
Chris Young 2011-12-04 20:06:53 +00:00
parent 2ff45272d0
commit ccbca43457
1 changed files with 8 additions and 7 deletions

View File

@ -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;
}