From 96b19a1c30be9df3da090dabba048b602e48371c Mon Sep 17 00:00:00 2001
From: Juraj Fedel <wtxnh-scribus@yahoo.com.au>
Date: Sat, 10 Oct 2015 11:22:00 +0200
Subject: [PATCH 1/7] --prefs option without provided file causes crash

Scribus crashes with Signal #6 when file argument is not provided to --prefs
or --python-script

$ scribus-1.5.1.svn -pr
ASSERT failure in QList<T>::operator[]: "index out of range", file
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h, line 487
Scribus Crash
-------------
Scribus crashes due to Signal #6
---
 scribus/scribusapp.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/scribus/scribusapp.cpp b/scribus/scribusapp.cpp
index bbc7357..f9b0eec 100644
--- a/scribus/scribusapp.cpp
+++ b/scribus/scribusapp.cpp
@@ -229,6 +229,10 @@ void ScribusQApp::parseCommandLine()
 			// last argument. FIXME: Qt only understands -display not --display and -d , we need to work
 			// around this.
 		} else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) {
+			if (argi+1 == argsc) {
+				std::cout << tr("Option %1 require an argument.").arg(arg).toLocal8Bit().data() << std::endl;
+				std::exit(EXIT_FAILURE);
+			}
 			prefsUserFile = QFile::decodeName(args[argi + 1].toLocal8Bit());
 			if (!QFileInfo(prefsUserFile).exists()) {
 				showError(prefsUserFile);
@@ -240,6 +244,10 @@ void ScribusQApp::parseCommandLine()
 		{
 			// Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted.
 		} else if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) {
+			if (argi+1 == argsc) {
+				std::cout << tr("Option %1 require an argument.").arg(arg).toLocal8Bit().data() << std::endl;
+				std::exit(EXIT_FAILURE);
+			}
 			pythonScript = QFile::decodeName(args[argi + 1].toLocal8Bit());
 			if (!QFileInfo(pythonScript).exists()) {
 				showError(pythonScript);
-- 
2.1.4

