Skip to content

Commit 6f3f47e

Browse files
author
Andi Gutmans
committed
- Fix off by one error in allocating command line (by Shane)
1 parent 7efccca commit 6f3f47e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

TSRM/tsrm_win32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ TSRM_API FILE* popen(const char *command, const char *type)
135135
startup.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
136136
}
137137

138-
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+4);
138+
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c "));
139139
sprintf(cmd, "%s /c %s", TWG(comspec), command);
140140
if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &process)) {
141141
return NULL;
@@ -184,4 +184,4 @@ TSRM_API int pclose(FILE* stream)
184184
return termstat;
185185
}
186186

187-
#endif
187+
#endif

0 commit comments

Comments
 (0)