r20405 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Sat Sep 19 21:52:28 UTC 2015


Author: jghali
Date: Sat Sep 19 21:52:28 2015
New Revision: 20405

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20405
Log:
fix incorrect null termination of string

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20405&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp	Sat Sep 19 21:52:28 2015
@@ -275,8 +275,10 @@
 	char **comm = new char*[arguments.size()];
 	for (int i = 0; i < arguments.size(); i++)
 	{
-		comm[i] = new char[arguments.at(i).toLocal8Bit().size()+1]; //+1 to allow adding '\0'. may be useless, don't know how to check.
-		strcpy(comm[i],arguments.at(i).toLocal8Bit().data()+'\0');
+		QByteArray localStr = arguments.at(i).toLocal8Bit();
+		comm[i] = new char[localStr.size() + 1]; //+1 to allow adding '\0'. may be useless, don't know how to check.
+		comm[i][localStr.size()] = 0;
+		strncpy(comm[i], localStr.data(), localStr.size());
 	}
 	PySys_SetArgv(arguments.size(), comm);
 




More information about the scribus-commit mailing list