r24852 by jghali - Fix potential dereferencing of end() iterator in SCFontsIterator::next()

scribus-commit scribus-commit at lists.scribus.net
Sun Jan 30 03:46:18 UTC 2022


Author: jghali
Date: Sun Jan 30 03:46:17 2022
New Revision: 24852

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24852
Log:
Fix potential dereferencing of end() iterator in SCFontsIterator::next()

Modified:
    branches/Version15x/Scribus/scribus/scfonts.cpp
    branches/Version15x/Scribus/scribus/scfonts.h

Modified: branches/Version15x/Scribus/scribus/scfonts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24852&path=/branches/Version15x/Scribus/scribus/scfonts.cpp
==============================================================================
--- branches/Version15x/Scribus/scribus/scfonts.cpp	(original)
+++ branches/Version15x/Scribus/scribus/scfonts.cpp	Sun Jan 30 03:46:17 2022
@@ -88,24 +88,26 @@
 void SCFonts::updateFontMap()
 {
 	fontMap.clear();
+
 	SCFontsIterator it( *this );
 	for ( ; it.hasNext(); it.next())
 	{
-		if (it.current().usable())
-		{
-			if (fontMap.contains(it.current().family()))
-			{
-				if (!fontMap[it.current().family()].contains(it.current().style()))
-				{
-					fontMap[it.current().family()].append(it.current().style());
-				}
-			}
-			else
-			{
-				QStringList styles;
-				styles.append(it.current().style());
-				fontMap.insert(it.current().family(), styles);
-			}
+		ScFace& currentFace = it.current();
+		if (!currentFace.usable())
+			continue;
+
+		if (fontMap.contains(currentFace.family()))
+		{
+			if (!fontMap[currentFace.family()].contains(currentFace.style()))
+			{
+				fontMap[currentFace.family()].append(currentFace.style());
+			}
+		}
+		else
+		{
+			QStringList styles;
+			styles.append(currentFace.style());
+			fontMap.insert(currentFace.family(), styles);
 		}
 	}
 }

Modified: branches/Version15x/Scribus/scribus/scfonts.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24852&path=/branches/Version15x/Scribus/scribus/scfonts.h
==============================================================================
--- branches/Version15x/Scribus/scribus/scfonts.h	(original)
+++ branches/Version15x/Scribus/scribus/scfonts.h	Sun Jan 30 03:46:17 2022
@@ -95,7 +95,7 @@
 	ScFace& current()          { return *m_it; }
 	QString currentKey() const { return m_it.key(); }
 	bool hasNext()       const { return m_it != m_end_it; }
-	ScFace& next()             { ++m_it; return current(); }
+	void next()                { ++m_it; }
 
 private:
 	QMap<QString, ScFace>::Iterator m_it;




More information about the scribus-commit mailing list