From 1d88ecc7535372989bd4b528cf4e6145fb69b2c9 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Thu, 8 Dec 2016 23:46:31 -0800 Subject: [PATCH] Fix Py_SetPythonHome calling The pointer for Py_SetPythonHome shouldn't be freed --- src/if_python3.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/if_python3.c b/src/if_python3.c index d9ec5db581..dccf2fc38b 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -861,15 +861,16 @@ Python3_Init(void) init_structs(); #ifdef DYNAMIC_PYTHON3 - if (p_py3home && *p_py3home != '\0') + if (*p_py3home != '\0') { int len; wchar_t *buf; len = mbstowcs(NULL, (char *)p_py3home, 0) + 1; buf = (wchar_t *)alloc(len * sizeof(wchar_t)); - if (buf && mbstowcs(buf, (char *)p_py3home, len) != (size_t)-1) + if (buf && mbstowcs(buf, (char *)p_py3home, len) != (size_t)-1) { Py_SetPythonHome(buf); - vim_free(buf); + /* We must keep buf for Py_SetPythonHome */ + } } # ifdef PYTHON3_HOME else if (mch_getenv((char_u *)"PYTHONHOME") == NULL)