[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 3294f6f69cc12b31e45d771d6cadbf19b83b92d7
Eugeniy Meshcheryakov
eugen at debian.org
Thu May 15 19:37:05 UTC 2008
The following commit has been merged in the master branch:
commit 3294f6f69cc12b31e45d771d6cadbf19b83b92d7
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Thu May 15 21:37:00 2008 +0200
check list sizes; fixes crash when importing invalid/new SFD
diff --git a/filters/sfdimportfilter.cxx b/filters/sfdimportfilter.cxx
index f609e57..909cde3 100644
--- a/filters/sfdimportfilter.cxx
+++ b/filters/sfdimportfilter.cxx
@@ -69,11 +69,13 @@ QStringList SFDImportFilter::errors() const
void SFDImportFilter::addError(const QString &text)
{
m_errors << QString("Error: %1").arg(text);
+ qDebug() << QString("Error: %1").arg(text);
}
void SFDImportFilter::addWarning(const QString &text)
{
m_errors << QString("Warning: %1").arg(text);
+ qDebug() << QString("Warning: %1").arg(text);
}
/***************************** Private part ********************************/
@@ -434,6 +436,10 @@ Glyph *SFDImportFilterPriv::readGlyph(const QString &name, QTextStream *sfd)
// <something> <unicode or -1> <glyph index>
QStringList values = value.split(" ", QString::SkipEmptyParts);
+ if (values.size() < 3) {
+ m_filter->addError("Bad file format: too few arguments for 'Encoding'");
+ goto fail;
+ }
int unicode = values[1].toInt();
if (unicode > 0)
g->setUnicode(unicode);
@@ -505,7 +511,8 @@ bool SFDImportFilterPriv::readGlyphContent(Glyph *g, QTextStream *sfd)
else
ops = line.split(" ", QString::SkipEmptyParts);
- if (lastLine || ops[2] == "m") {
+ // TODO fix those sizes
+ if (lastLine || (ops.size() >= 3 && ops[2] == "m")) {
if (!points.isEmpty()) {
bool cntOpen = true;
if ((points.size() > 1) && PT_EQ(points.first(), lastPt)) {
@@ -533,14 +540,14 @@ bool SFDImportFilterPriv::readGlyphContent(Glyph *g, QTextStream *sfd)
lastIn = false;
hasCnt = true;
}
- else if (ops[2] == "l") {
+ else if (ops.size() >= 3 && ops[2] == "l") {
if (!hasCnt)
return false; // TODO bad file format
lastPt = GlyphPoint(ops[0].toDouble(), ops[1].toDouble());
points << lastPt;
lastIn = false;
}
- else if (ops[6] == "c") {
+ else if (ops.size() >= 8 && ops[6] == "c") {
if (!hasCnt)
return false; // TODO bad file format
QStringList flags = ops[7].split(",");
@@ -577,6 +584,10 @@ bool SFDImportFilterPriv::processReferences(FontDocument *doc)
foreach(const QString &ref, i.value()) {
QStringList args = ref.split(" ", QString::SkipEmptyParts);
+ if (args.size() < 9) {
+ m_filter->addError("Bad reference format");
+ return false;
+ }
int glyphIndex = args[0].toInt();
QString otherName = toNameMap[glyphIndex];
if (otherName.isNull())
--
Fondue Font Editor
More information about the fondue-commits
mailing list