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 https://github.com/mstorsjo/llvm-mingw/issues/296.
This commit is contained in:
1 parent
51cb479cb4
commit
3847488786
1 file changed
+5
-1
@@ -58,7 +58,11 @@ typedef char TCHAR;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
static inline TCHAR *escape(const TCHAR *str) {
|
||||
static inline const TCHAR *escape(const TCHAR *str) {
|
||||
// If we don't need to escape anything, just return the input string
|
||||
// as is.
|
||||
if (!_tcschr(str, ' ') && !_tcschr(str, '"'))
|
||||
return str;
|
||||
TCHAR *out = malloc((_tcslen(str) * 2 + 3) * sizeof(*out));
|
||||
TCHAR *ptr = out;
|
||||
int i;
|
||||
|
||||
Reference in new issue
Block a user