aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/Windows/Program.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/Windows/Program.inc')
-rw-r--r--lib/Support/Windows/Program.inc9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Support/Windows/Program.inc b/lib/Support/Windows/Program.inc
index 4a4ed2f84b..619ae5d8f7 100644
--- a/lib/Support/Windows/Program.inc
+++ b/lib/Support/Windows/Program.inc
@@ -155,7 +155,8 @@ static char *EscapePrecedingEscapes(char *Dst, const char *Start,
/// CreateProcess and returns length of quoted arg with escaped quotes
static unsigned int ArgLenWithQuotes(const char *Str) {
const char *Start = Str;
- unsigned int len = ArgNeedsQuotes(Str) ? 2 : 0;
+ bool Quoted = ArgNeedsQuotes(Str);
+ unsigned int len = Quoted ? 2 : 0;
while (*Str != '\0') {
if (*Str == '\"') {
@@ -171,6 +172,12 @@ static unsigned int ArgLenWithQuotes(const char *Str) {
++Str;
}
+ if (Quoted) {
+ // Make sure the closing quote doesn't get escaped by a trailing backslash.
+ unsigned PrecedingEscapes = CountPrecedingBackslashes(Start, Str);
+ len += PrecedingEscapes + 1;
+ }
+
return len;
}