r21991 by craig - Coverity 1350068: Unchecked return value in ScDocOutput begin, convert to return bool and don't run the rest of the code if failed to open

scribus-commit scribus-commit at lists.scribus.net
Sun Apr 23 10:01:56 UTC 2017


Author: craig
Date: Sun Apr 23 10:01:56 2017
New Revision: 21991

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21991
Log:
Coverity 1350068: Unchecked return value in ScDocOutput begin, convert to return bool and don't run the rest of the code if failed to open

Modified:
    trunk/Scribus/scribus/scdocoutput.cpp
    trunk/Scribus/scribus/scdocoutput.h
    trunk/Scribus/scribus/scdocoutput_ps2.cpp
    trunk/Scribus/scribus/scdocoutput_ps2.h

Modified: trunk/Scribus/scribus/scdocoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21991&path=/trunk/Scribus/scribus/scdocoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/scdocoutput.cpp	(original)
+++ trunk/Scribus/scribus/scdocoutput.cpp	Sun Apr 23 10:01:56 2017
@@ -11,10 +11,11 @@
 
 bool ScDocOutput::makeOutput(ScribusDoc* doc, vector<int>& pageNumbers)
 {
-	bool  done = true;
+	if (!begin())
+		return false;
+
+	bool done = true;
 	ScPage* page;
-
-	begin();
 
 	for (uint index = 0; index < pageNumbers.size(); index++)
 	{
@@ -33,8 +34,6 @@
 			break;
 		}
 	}
-
 	end();
-
 	return done;
 }

Modified: trunk/Scribus/scribus/scdocoutput.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21991&path=/trunk/Scribus/scribus/scdocoutput.h
==============================================================================
--- trunk/Scribus/scribus/scdocoutput.h	(original)
+++ trunk/Scribus/scribus/scdocoutput.h	Sun Apr 23 10:01:56 2017
@@ -20,7 +20,7 @@
 protected:
 	ScDocOutput() {}
 
-	virtual void begin(void) {}
+	virtual bool begin(void) {}
 	virtual void end(void) {}
 
 	virtual ScPageOutput* createPageOutputComponent(int pageIndex) { return NULL; }

Modified: trunk/Scribus/scribus/scdocoutput_ps2.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21991&path=/trunk/Scribus/scribus/scdocoutput_ps2.cpp
==============================================================================
--- trunk/Scribus/scribus/scdocoutput_ps2.cpp	(original)
+++ trunk/Scribus/scribus/scdocoutput_ps2.cpp	Sun Apr 23 10:01:56 2017
@@ -35,9 +35,13 @@
 		m_file.close();
 }
 
-void ScDocOutput_Ps2::begin(void)
+bool ScDocOutput_Ps2::begin(void)
 {
-	m_file.open(QIODevice::WriteOnly);
+	if (!m_file.open(QIODevice::WriteOnly))
+	{
+		qDebug()<<"Unable to open file in ScDocOutput_Ps2::begin";
+		return false;
+	}
 	m_stream.setDevice(&m_file);
 
 	m_stream << "%!PS-Adobe-2.0\n";
@@ -61,6 +65,7 @@
 	m_stream << QString("<< /PageSize [ %1 %2 ]\n").arg((int) m_clip.width()).arg((int) m_clip.height());
 	m_stream << ">> setpagedevice\n";
 	m_stream << "%%EndSetup\n";
+	return true;
 }
 
 void ScDocOutput_Ps2::end(void)

Modified: trunk/Scribus/scribus/scdocoutput_ps2.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21991&path=/trunk/Scribus/scribus/scdocoutput_ps2.h
==============================================================================
--- trunk/Scribus/scribus/scdocoutput_ps2.h	(original)
+++ trunk/Scribus/scribus/scdocoutput_ps2.h	Sun Apr 23 10:01:56 2017
@@ -40,7 +40,7 @@
 
 	QRect   m_clip;
 
-	virtual void begin(void);
+	virtual bool begin(void);
 	virtual void end(void);
 
 	virtual ScPageOutput* createPageOutputComponent(int pageIndex);




More information about the scribus-commit mailing list