cleanup and return in error case, otherwise a stale style pointer could be added to the family. CID 1246

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27524 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2008-09-15 12:26:43 +00:00
parent 437ecc65ae
commit a57b0996eb
+4 -1
View File
@@ -563,8 +563,11 @@ FontManager::_AddFont(font_directory& directory, BEntry& entry)
// the FontStyle takes over ownership of the FT_Face object // the FontStyle takes over ownership of the FT_Face object
FontStyle *style = new FontStyle(nodeRef, path.Path(), face); FontStyle *style = new FontStyle(nodeRef, path.Path(), face);
if (!family->AddStyle(style)) if (!family->AddStyle(style)) {
delete style; delete style;
delete family;
return B_NO_MEMORY;
}
directory.styles.AddItem(style); directory.styles.AddItem(style);
fStyleHashTable.AddItem(style); fStyleHashTable.AddItem(style);