Small fix that might or might not fix "EFAULT (bad address)"-errors when executing scripts on events

This commit is contained in:
Stefan Persson 2014-03-06 14:13:29 +01:00
parent c542059299
commit 1f93cf91f8

View file

@ -226,7 +226,7 @@ void EventUpdateManager::executeScripts(EventUpdateData *data) {
newEnv[i] = new char[env.at(i).length()+1];
snprintf(newEnv[i], env.at(i).length()+1, "%s", env.at(i).c_str());
}
newEnv[env.size()] = 0; // Mark end of array
newEnv[env.size()] = NULL; // Mark end of array
for(StringList::iterator it = d->fileList[dir].begin(); it != d->fileList[dir].end(); ++it) {
executeScript(TelldusCore::formatf("%s/%s/%s", SCRIPT_PATH, dir.c_str(), (*it).c_str()), (*it), newEnv);
@ -249,7 +249,7 @@ void EventUpdateManager::executeScript(std::string script, const std::string &na
if (pid == 0) {
char *n = new char[name.length()+1];
snprintf(n, name.length()+1, "%s", name.c_str());
static char * argv[] = { n };
static char * argv[] = { n, NULL };
execve(script.c_str(), argv, env);
delete[] n;
Log::error("Could not execute %s (%i): %s", script.c_str(), errno, strerror(errno));