r21988 by craig - Coverity 1350061: Unchecked return value on file open

scribus-commit scribus-commit at lists.scribus.net
Sun Apr 23 09:51:21 UTC 2017


Author: craig
Date: Sun Apr 23 09:51:21 2017
New Revision: 21988

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

Modified:
    trunk/Scribus/scribus/ui/latexeditor.cpp

Modified: trunk/Scribus/scribus/ui/latexeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21988&path=/trunk/Scribus/scribus/ui/latexeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/latexeditor.cpp	(original)
+++ trunk/Scribus/scribus/ui/latexeditor.cpp	Sun Apr 23 09:51:21 2017
@@ -159,10 +159,11 @@
 	fileWatcher->disconnect(); //Avoid triggering false updates
 
 	//First create a temp file name
-	if (extEditorFile.isEmpty()) {
-		QTemporaryFile *editortempfile = new QTemporaryFile(
-			QDir::tempPath() + "/scribus_temp_editor_XXXXXX");
-		if (!editortempfile->open()) {
+	if (extEditorFile.isEmpty())
+	{
+		QTemporaryFile *editortempfile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_editor_XXXXXX");
+		if (!editortempfile->open())
+		{
 			ScMessageBox::critical(0, tr("Error"), "<qt>" + 
 				tr("Could not create a temporary file to run the external editor!")
 				+ "</qt>");
@@ -174,12 +175,15 @@
 		fileWatcher->addFile(extEditorFile);
 	}
 	QFile f(extEditorFile);
-	f.open(QIODevice::WriteOnly);
+	if(!f.open(QIODevice::WriteOnly))
+	{
+		qDebug()<<"Unable to open editor file in LatexEditor::writeExternalEditorFile()";
+		return;
+	}
 	f.write(frame->formula().toUtf8());
 	f.close();
 	fileWatcher->forceScan();
-	connect(fileWatcher, SIGNAL(fileChanged(QString)),
-		this, SLOT(extEditorFileChanged(QString)));
+	connect(fileWatcher, SIGNAL(fileChanged(QString)), this, SLOT(extEditorFileChanged(QString)));
 	fileWatcher->start();
 }
 




More information about the scribus-commit mailing list