From a57b0996eb7e0f8d72bc45342eae6d712d163be4 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Mon, 15 Sep 2008 12:26:43 +0000 Subject: [PATCH] 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 --- src/servers/app/FontManager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/servers/app/FontManager.cpp b/src/servers/app/FontManager.cpp index 464a7bb52c..ebbff0a1f2 100644 --- a/src/servers/app/FontManager.cpp +++ b/src/servers/app/FontManager.cpp @@ -541,7 +541,7 @@ FontManager::_AddFont(font_directory& directory, BEntry& entry) if (error != 0) return B_ERROR; - FontFamily *family = _FindFamily(face->family_name); + FontFamily *family = _FindFamily(face->family_name); if (family != NULL && family->HasStyle(face->style_name)) { // prevent adding the same style twice // (this indicates a problem with the installed fonts maybe?) @@ -562,9 +562,12 @@ FontManager::_AddFont(font_directory& directory, BEntry& entry) FTRACE(("\tadd style: %s, %s\n", face->family_name, face->style_name)); // the FontStyle takes over ownership of the FT_Face object - FontStyle *style = new FontStyle(nodeRef, path.Path(), face); - if (!family->AddStyle(style)) + FontStyle *style = new FontStyle(nodeRef, path.Path(), face); + if (!family->AddStyle(style)) { delete style; + delete family; + return B_NO_MEMORY; + } directory.styles.AddItem(style); fStyleHashTable.AddItem(style);