SystemExec: copy last argument from command line to argv[]
authorColin Fletcher <colin.m.fletcher@googlemail.com>
Sun, 18 May 2014 19:49:58 +0000 (20:49 +0100)
committerColin Fletcher <colin.m.fletcher@googlemail.com>
Sun, 18 May 2014 19:49:58 +0000 (20:49 +0100)
Make sure to copy any part of the command line after the last delimiter
to argv[] when creating a SystemExec with an escaped command line.

libs/pbd/system_exec.cc

index f270364660a39e53d2bdd3c7eb1cdea17bd64a16..bf02fd72540d39a0beca7022529b9ff4783cdcae 100644 (file)
@@ -201,7 +201,7 @@ SystemExec::make_argp_escaped(std::string command, const std::map<char, std::str
 
        argp = (char **) malloc(sizeof(char *));
 
-       for (i = 0; i < command.length(); i++) {
+       for (i = 0; i <= command.length(); i++) { // include terminating '\0'
                char c = command.c_str()[i];
                if (inquotes) {
                        if (c == '"') {
@@ -244,6 +244,7 @@ SystemExec::make_argp_escaped(std::string command, const std::map<char, std::str
                                break;
                        case ' ' :
                        case '\t':
+                       case '\0':
                                if (arg.length() > 0) {
                                        // if there wasn't already a space or tab, start a new parameter
                                        argp = (char **) realloc(argp, (n + 2) * sizeof(char *));