r21992 by craig - Coverity 1350069: Unchecked return value on file open

scribus-commit scribus-commit at lists.scribus.net
Sun Apr 23 10:04:48 UTC 2017


Author: craig
Date: Sun Apr 23 10:04:48 2017
New Revision: 21992

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21992
Log:
Coverity 1350069: Unchecked return value on file open

Modified:
    trunk/Scribus/scribus/plugins/barcodegenerator/barcodegeneratorrenderthread.cpp

Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegeneratorrenderthread.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21992&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegeneratorrenderthread.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegeneratorrenderthread.cpp	(original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegeneratorrenderthread.cpp	Sun Apr 23 10:04:48 2017
@@ -76,20 +76,23 @@
 		int gs = callGS(gargs, QString(), fileStdErr, fileStdOut);
 		bool retval = gs==0 && QFile::exists(pngFile);   // GS returns 0 for BWIPP-handled errors
 
-		QString errorMsg="";
-		if (!retval) {
+		QString errorMsg;
+		if (!retval)
+		{
 			errorMsg="Barcode incomplete";
 			if (QFile::exists(fileStdErr))  // Display BWIPP handled error message
 			{
 				QFile f(fileStdErr);
-				f.open(QIODevice::ReadOnly);
-				QTextStream ts(&f);
-				QString err = ts.readAll();
-				f.close();
-				QRegExp rx("[\\r\\n]+BWIPP ERROR: [^\\s]+ (.*)[\\r\\n$]+");
-				rx.setMinimal(true);
-				if (rx.indexIn(err) != -1)
-					errorMsg=rx.cap(1).trimmed();
+				if (f.open(QIODevice::ReadOnly))
+				{
+					QTextStream ts(&f);
+					QString err = ts.readAll();
+					f.close();
+					QRegExp rx("[\\r\\n]+BWIPP ERROR: [^\\s]+ (.*)[\\r\\n$]+");
+					rx.setMinimal(true);
+					if (rx.indexIn(err) != -1)
+						errorMsg=rx.cap(1).trimmed();
+				}
 			}
 		}
 




More information about the scribus-commit mailing list