r20975 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Thu Feb 11 20:45:36 UTC 2016
Author: jghali
Date: Thu Feb 11 20:45:36 2016
New Revision: 20975
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20975
Log:
attempt to fix coverity #1350557: dereference before null check
Modified:
trunk/Scribus/scribus/scfonts.cpp
Modified: trunk/Scribus/scribus/scfonts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20975&path=/trunk/Scribus/scribus/scfonts.cpp
==============================================================================
--- trunk/Scribus/scribus/scfonts.cpp (original)
+++ trunk/Scribus/scribus/scfonts.cpp Thu Feb 11 20:45:36 2016
@@ -322,7 +322,7 @@
ScFace::FontType type;
FT_Face face = NULL;
error = FT_New_Face(library, QFile::encodeName(filename), 0, &face);
- if (error)
+ if (error || (face == NULL))
{
if (face != NULL)
FT_Done_Face(face);
@@ -332,37 +332,34 @@
getFontFormat(face, format, type);
if (format == ScFace::UNKNOWN_FORMAT)
{
- if (face != NULL)
- FT_Done_Face(face);
+ FT_Done_Face(face);
FT_Done_FreeType(library);
return t;
}
bool HasNames = FT_HAS_GLYPH_NAMES(face);
- if (!error)
- {
- FT_UInt gindex = 0;
- FT_ULong charcode = FT_Get_First_Char( face, &gindex );
- while ( gindex != 0 )
- {
- error = FT_Load_Glyph(face, gindex, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP);
- if (error)
- {
- if (face != NULL)
- FT_Done_Face(face);
- FT_Done_FreeType(library);
- return t;
- }
- FT_Get_Glyph_Name(face, gindex, buf, 50);
- QString newName = QString(reinterpret_cast<char*>(buf));
- if (newName == glyName)
- {
- HasNames = false;
- Subset = true;
- }
- glyName = newName;
- charcode = FT_Get_Next_Char(face, charcode, &gindex);
- }
- }
+
+ FT_UInt gindex = 0;
+ FT_ULong charcode = FT_Get_First_Char(face, &gindex);
+ while (gindex != 0)
+ {
+ error = FT_Load_Glyph(face, gindex, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP);
+ if (error)
+ {
+ FT_Done_Face(face);
+ FT_Done_FreeType(library);
+ return t;
+ }
+ FT_Get_Glyph_Name(face, gindex, buf, 50);
+ QString newName = QString(reinterpret_cast<char*>(buf));
+ if (newName == glyName)
+ {
+ HasNames = false;
+ Subset = true;
+ }
+ glyName = newName;
+ charcode = FT_Get_Next_Char(face, charcode, &gindex);
+ }
+
int faceIndex=0;
QString fam(face->family_name);
QString sty(face->style_name);
@@ -415,7 +412,7 @@
t.subset(Subset);
break;
default:
- /* catching any types not handled above to silence compiler */
+ /* catching any types not handled above to silence compiler */
break;
}
t.m_m->hasGlyphNames = HasNames;
More information about the scribus-commit
mailing list