r22306 by craig -

scribus-commit scribus-commit at lists.scribus.net
Fri Dec 29 23:04:36 UTC 2017


Author: craig
Date: Fri Dec 29 23:04:36 2017
New Revision: 22306

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22306
Log:
Fix Coverity 1350615

Modified:
    trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp

Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22306&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp	(original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp	Fri Dec 29 23:04:36 2017
@@ -40,11 +40,25 @@
 #endif
 }
 
-ScImgDataLoader_PS::ScImgDataLoader_PS(void) : ScImgDataLoader()
-{
-	m_doThumbnail = false;
-	m_hasThumbnail = false;
-
+ScImgDataLoader_PS::ScImgDataLoader_PS(void) : ScImgDataLoader(),
+	 m_isDCS1(false),
+	 m_isDCS2(false),
+	 m_isDCS2multi(false),
+	 m_isPhotoshop(false),
+	 m_hasPhotoshopImageData(false),
+	 m_doThumbnail(false),
+	 m_hasThumbnail(false),
+	 m_inTrailer(false),
+	 m_BBoxInTrailer(false),
+	 m_isRotated(false),
+	 m_psXSize(0),
+	 m_psYSize(0),
+	 m_psDepth(0),
+	 m_psMode(0),
+	 m_psChannel(0),
+	 m_psBlock(0),
+	 m_psDataType(0)
+{
 	initSupportedFormatList();
 }
 
@@ -66,48 +80,47 @@
 
 void ScImgDataLoader_PS::loadEmbeddedProfile(const QString& fn, int /* page */)
 {
-	QChar tc;
-	QString tmp;
 	m_embeddedProfile.resize(0);
 	m_profileComponents = 0;
 	if ( !QFile::exists(fn) )
 		return;
 	QFile f(fn);
-	if (f.open(QIODevice::ReadOnly))
-	{
-		QDataStream ts(&f);
-		while (!ts.atEnd())
-		{
-			tmp = readLinefromDataStream(ts);
-			if (tmp.startsWith("%%BeginICCProfile:"))
-			{
-				QByteArray psdata;
-				while (!ts.atEnd())
-				{
-					tmp = readLinefromDataStream(ts);
-					for (int a = 2; a < tmp.length(); a += 2)
-					{
-						bool ok;
-						ushort data = tmp.midRef(a, 2).toUShort(&ok, 16);
-						psdata.resize(psdata.size()+1);
-						psdata[psdata.size()-1] = data;
-					}
-					if (tmp.startsWith("%%EndICCProfile"))
-					{
-						ScColorMgmtEngine engine(ScCore->defaultEngine);
-						ScColorProfile prof = engine.openProfileFromMem(psdata);
-						if (prof)
-						{
-							if (prof.colorSpace() == ColorSpace_Rgb)
-								m_profileComponents = 3;
-							if (prof.colorSpace() == ColorSpace_Cmyk)
-								m_profileComponents = 4;
-							m_imageInfoRecord.profileName = prof.productDescription();
-							m_imageInfoRecord.isEmbedded = true;
-							m_embeddedProfile = psdata;
-						}
-						break;
-					}
+	if (!f.open(QIODevice::ReadOnly))
+		return;
+
+	QString tmp;
+	QDataStream ts(&f);
+	while (!ts.atEnd())
+	{
+		tmp = readLinefromDataStream(ts);
+		if (tmp.startsWith("%%BeginICCProfile:"))
+		{
+			QByteArray psdata;
+			while (!ts.atEnd())
+			{
+				tmp = readLinefromDataStream(ts);
+				for (int a = 2; a < tmp.length(); a += 2)
+				{
+					bool ok;
+					ushort data = tmp.midRef(a, 2).toUShort(&ok, 16);
+					psdata.resize(psdata.size()+1);
+					psdata[psdata.size()-1] = data;
+				}
+				if (tmp.startsWith("%%EndICCProfile"))
+				{
+					ScColorMgmtEngine engine(ScCore->defaultEngine);
+					ScColorProfile prof = engine.openProfileFromMem(psdata);
+					if (prof)
+					{
+						if (prof.colorSpace() == ColorSpace_Rgb)
+							m_profileComponents = 3;
+						if (prof.colorSpace() == ColorSpace_Cmyk)
+							m_profileComponents = 4;
+						m_imageInfoRecord.profileName = prof.productDescription();
+						m_imageInfoRecord.isEmbedded = true;
+						m_embeddedProfile = psdata;
+					}
+					break;
 				}
 			}
 		}
@@ -116,22 +129,21 @@
 
 void ScImgDataLoader_PS::scanForFonts(QString fn)
 {
+	QFile f(fn);
+	if (!f.open(QIODevice::ReadOnly))
+		return;
+	QDataStream ts(&f);
 	QString tmp;
-	QFile f(fn);
-	if (f.open(QIODevice::ReadOnly))
-	{
-		QDataStream ts(&f);
-		while (!ts.atEnd())
-		{
-			tmp = readLinefromDataStream(ts);
-			if (tmp.startsWith("%%BeginFont:"))
-			{
-				tmp = tmp.remove("%%BeginFont:");
-				ScTextStream ts2(&tmp, QIODevice::ReadOnly);
-				QString tmp2;
-				ts2 >> tmp2;
-				m_FontListe.removeAll(tmp2);
-			}
+	while (!ts.atEnd())
+	{
+		tmp = readLinefromDataStream(ts);
+		if (tmp.startsWith("%%BeginFont:"))
+		{
+			tmp = tmp.remove("%%BeginFont:");
+			ScTextStream ts2(&tmp, QIODevice::ReadOnly);
+			QString tmp2;
+			ts2 >> tmp2;
+			m_FontListe.removeAll(tmp2);
 		}
 	}
 }
@@ -738,7 +750,6 @@
 		return;
 	}
 	QStringList args;
-	double x, y, b, h;
 	QFileInfo fi = QFileInfo(fn);
 	QString ext = fi.suffix().toLower();
 	QString tmpFile = QDir::toNativeSeparators(ScPaths::tempFileDir() + "sc1.png");
@@ -747,6 +758,7 @@
 	int GsMinor;
 	getNumericGSVersion(GsMajor, GsMinor);
 	ScTextStream ts2(&m_BBox, QIODevice::ReadOnly);
+	double x, y, b, h;
 	ts2 >> x >> y >> b >> h;
 	h = h * gsRes / 72.0;
 	if (extensionIndicatesEPS(ext))
@@ -1170,7 +1182,7 @@
 	double x, y, b, h;
 	ScTextStream ts2(&m_BBox, QIODevice::ReadOnly);
 	ts2 >> x >> y >> b >> h;
-	QString tmpFile = QDir::toNativeSeparators(ScPaths::tempFileDir() + "sc1.jpg");
+	QString tmpFile(QDir::toNativeSeparators(ScPaths::tempFileDir() + "sc1.jpg"));
 	QFile f2(tmpFile);
 	QString tmp;
 	m_image = QImage(m_psXSize, m_psYSize, QImage::Format_ARGB32);




More information about the scribus-commit mailing list