Skip to content

Commit 7c7e807

Browse files
authored
Merge pull request #434 from macvim-dev/fix/pythonthreehome
Fix Py_SetPythonHome calling
2 parents 5ff38b0 + 1d88ecc commit 7c7e807

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/if_python3.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -861,15 +861,16 @@ Python3_Init(void)
861861
init_structs();
862862

863863
#ifdef DYNAMIC_PYTHON3
864-
if (p_py3home && *p_py3home != '\0')
864+
if (*p_py3home != '\0')
865865
{
866866
int len;
867867
wchar_t *buf;
868868
len = mbstowcs(NULL, (char *)p_py3home, 0) + 1;
869869
buf = (wchar_t *)alloc(len * sizeof(wchar_t));
870-
if (buf && mbstowcs(buf, (char *)p_py3home, len) != (size_t)-1)
870+
if (buf && mbstowcs(buf, (char *)p_py3home, len) != (size_t)-1) {
871871
Py_SetPythonHome(buf);
872-
vim_free(buf);
872+
/* We must keep buf for Py_SetPythonHome */
873+
}
873874
}
874875
# ifdef PYTHON3_HOME
875876
else if (mch_getenv((char_u *)"PYTHONHOME") == NULL)

0 commit comments

Comments
 (0)