diff options
author | Bram Moolenaar <Bram@vim.org> | 2012-09-12 20:21:43 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2012-09-12 20:21:43 +0200 |
commit | e8cdcef87575cacbc9dd977de076af76e4405410 (patch) | |
tree | fad755d283aa655a961f5c9a7ec76b5fe56d0533 /src | |
parent | fca93c093e0ec86331171ca4e169f73aa81ebfef (diff) | |
download | vim-e8cdcef87575cacbc9dd977de076af76e4405410.zip |
updated for version 7.3.661
Problem: SEGV in Python code.
Solution: Initialize len to zero. Use the right function depending on
version. (Maxim Philippov)
Diffstat (limited to 'src')
-rw-r--r-- | src/if_py_both.h | 2 | ||||
-rw-r--r-- | src/if_python.c | 14 | ||||
-rw-r--r-- | src/if_python3.c | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 24 insertions, 7 deletions
diff --git a/src/if_py_both.h b/src/if_py_both.h index 0031003ed..5e12638f5 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -74,7 +74,7 @@ static struct PyMethodDef OutputMethods[] = { static PyObject * OutputWrite(PyObject *self, PyObject *args) { - Py_ssize_t len; + Py_ssize_t len = 0; char *str = NULL; int error = ((OutputObject *)(self))->error; diff --git a/src/if_python.c b/src/if_python.c index 385905e24..a20aba0f3 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -44,8 +44,6 @@ # undef _XOPEN_SOURCE /* pyconfig.h defines it as well. */ #endif -#define PY_SSIZE_T_CLEAN - #include <Python.h> #if defined(MACOS) && !defined(MACOS_X_UNIX) # include "macglue.h" @@ -54,6 +52,10 @@ #undef main /* Defined in python.h - aargh */ #undef HAVE_FCNTL_H /* Clash with os_win32.h */ +#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000 +# define PY_SSIZE_T_CLEAN +#endif + static void init_structs(void); #define PyBytes_FromString PyString_FromString @@ -358,8 +360,15 @@ static struct PYTHON_PROC *ptr; } python_funcname_table[] = { +#ifndef PY_SSIZE_T_CLEAN {"PyArg_Parse", (PYTHON_PROC*)&dll_PyArg_Parse}, {"PyArg_ParseTuple", (PYTHON_PROC*)&dll_PyArg_ParseTuple}, + {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue}, +#else + {"_PyArg_Parse_SizeT", (PYTHON_PROC*)&dll_PyArg_Parse}, + {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&dll_PyArg_ParseTuple}, + {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&dll_Py_BuildValue}, +#endif {"PyMem_Free", (PYTHON_PROC*)&dll_PyMem_Free}, {"PyMem_Malloc", (PYTHON_PROC*)&dll_PyMem_Malloc}, {"PyDict_SetItemString", (PYTHON_PROC*)&dll_PyDict_SetItemString}, @@ -422,7 +431,6 @@ static struct {"PySys_SetArgv", (PYTHON_PROC*)&dll_PySys_SetArgv}, {"PyType_Type", (PYTHON_PROC*)&dll_PyType_Type}, {"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready}, - {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue}, {"Py_FindMethod", (PYTHON_PROC*)&dll_Py_FindMethod}, # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000 \ && SIZEOF_SIZE_T != SIZEOF_INT diff --git a/src/if_python3.c b/src/if_python3.c index 0c10f8dbc..43ed0e2a5 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -42,8 +42,6 @@ # undef _DEBUG #endif -#define PY_SSIZE_T_CLEAN - #ifdef F_BLANK # undef F_BLANK #endif @@ -66,6 +64,10 @@ #undef main /* Defined in python.h - aargh */ #undef HAVE_FCNTL_H /* Clash with os_win32.h */ +#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000 +# define PY_SSIZE_T_CLEAN +#endif + static void init_structs(void); /* The "surrogateescape" error handler is new in Python 3.1 */ @@ -328,7 +330,13 @@ static struct {"PySys_SetArgv", (PYTHON_PROC*)&py3_PySys_SetArgv}, {"Py_SetPythonHome", (PYTHON_PROC*)&py3_Py_SetPythonHome}, {"Py_Initialize", (PYTHON_PROC*)&py3_Py_Initialize}, +#ifndef PY_SSIZE_T_CLEAN {"PyArg_ParseTuple", (PYTHON_PROC*)&py3_PyArg_ParseTuple}, + {"Py_BuildValue", (PYTHON_PROC*)&py3_Py_BuildValue}, +#else + {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&py3_PyArg_ParseTuple}, + {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&py3_Py_BuildValue}, +#endif {"PyMem_Free", (PYTHON_PROC*)&py3_PyMem_Free}, {"PyMem_Malloc", (PYTHON_PROC*)&py3_PyMem_Malloc}, {"PyList_New", (PYTHON_PROC*)&py3_PyList_New}, @@ -364,7 +372,6 @@ static struct {"PyObject_GetIter", (PYTHON_PROC*)&py3_PyObject_GetIter}, {"PyLong_FromLong", (PYTHON_PROC*)&py3_PyLong_FromLong}, {"PyDict_New", (PYTHON_PROC*)&py3_PyDict_New}, - {"Py_BuildValue", (PYTHON_PROC*)&py3_Py_BuildValue}, {"PyType_Ready", (PYTHON_PROC*)&py3_PyType_Ready}, {"PyDict_SetItemString", (PYTHON_PROC*)&py3_PyDict_SetItemString}, {"PyLong_AsLong", (PYTHON_PROC*)&py3_PyLong_AsLong}, diff --git a/src/version.c b/src/version.c index 3851b3f88..4b1350647 100644 --- a/src/version.c +++ b/src/version.c @@ -720,6 +720,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 661, +/**/ 660, /**/ 659, |