Skip to content

Commit 1b5d754

Browse files
committed
Fixing split_venv_command_into_args
1 parent 5d6b350 commit 1b5d754

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

graalpython/python-macos-launcher/src/venvlauncher.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ char *get_pyenvcfg_command(const char *pyenv_cfg_path) {
115115
exit(1);
116116
}
117117

118-
char **split_venv_command_into_args(char *venv_command, int *argc_out) {
118+
char **split_venv_command_into_args(const char *venv_command, int *argc_out) {
119119

120120
char *copy = strdup(venv_command);
121121
size_t capacity = 5;
@@ -127,7 +127,7 @@ char **split_venv_command_into_args(char *venv_command, int *argc_out) {
127127
}
128128

129129
size_t count = 0;
130-
char *current_token = strtok(venv_command, " ");
130+
char *current_token = strtok(copy, " ");
131131
while (current_token) {
132132
if (count >= capacity) {
133133
capacity *= 2;
@@ -189,6 +189,8 @@ int main(int argc, char *argv[]) {
189189
char **venv_args = split_venv_command_into_args(venv_command, &venv_argc);
190190

191191
// Adds "--python.VenvlauncherCommand="
192+
// + 2 for quotes
193+
// + 1 for '\0'
192194
size_t python_base_exec_size = strlen(venv_command) + strlen(GRAAL_PYTHON_BASE_EXE_ARG) + 2 + 1;
193195
char python_base_exec_command[python_base_exec_size];
194196
snprintf(python_base_exec_command, python_base_exec_size, "%s\"%s\"", GRAAL_PYTHON_BASE_EXE_ARG, venv_command);

0 commit comments

Comments
 (0)