Skip to content

Commit 1d88ecc

Browse files
committed
Fix Py_SetPythonHome calling
The pointer for Py_SetPythonHome shouldn't be freed
1 parent 5ff38b0 commit 1d88ecc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/if_python3.c

Lines changed: 4 additions & 3 deletions
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)