Skip to content

Commit 3847488

Browse files
committed
wrappers: Only escape arguments that need escaping
This avoids inflating the total size of the command line too much. If the input command line is near the max size of a command line (32767 characters), it may grow past that limit when adding the arguments injected by the wrapper. If we excessively quote all arguments that don't need to be quoted, we can more easily run into this situation. Thus, by avoiding excessive quoting, we reduce the risk for this issue to happen. This avoids the issue reported at #296.
1 parent 51cb479 commit 3847488

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

wrappers/native-wrapper.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ typedef char TCHAR;
5858
#endif
5959

6060
#ifdef _WIN32
61-
static inline TCHAR *escape(const TCHAR *str) {
61+
static inline const TCHAR *escape(const TCHAR *str) {
62+
// If we don't need to escape anything, just return the input string
63+
// as is.
64+
if (!_tcschr(str, ' ') && !_tcschr(str, '"'))
65+
return str;
6266
TCHAR *out = malloc((_tcslen(str) * 2 + 3) * sizeof(*out));
6367
TCHAR *ptr = out;
6468
int i;

0 commit comments

Comments
 (0)