Karsten Hopp 2d4727
To: vim_dev@googlegroups.com
Karsten Hopp 2d4727
Subject: Patch 7.3.661
Karsten Hopp 2d4727
Fcc: outbox
Karsten Hopp 2d4727
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 2d4727
Mime-Version: 1.0
Karsten Hopp 2d4727
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 2d4727
Content-Transfer-Encoding: 8bit
Karsten Hopp 2d4727
------------
Karsten Hopp 2d4727
Karsten Hopp 2d4727
Patch 7.3.661 (after 7.3.652)
Karsten Hopp 2d4727
Problem:    SEGV in Python code.
Karsten Hopp 2d4727
Solution:   Initialize len to zero.  Use the right function depending on
Karsten Hopp 2d4727
	    version. (Maxim Philippov)
Karsten Hopp 2d4727
Files:	    src/if_py_both.h, src/if_python.c, src/if_python3.c
Karsten Hopp 2d4727
Karsten Hopp 2d4727
Karsten Hopp 2d4727
*** ../vim-7.3.660/src/if_py_both.h	2012-09-05 19:09:06.000000000 +0200
Karsten Hopp 2d4727
--- src/if_py_both.h	2012-09-12 19:50:07.000000000 +0200
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 74,80 ****
Karsten Hopp 2d4727
      static PyObject *
Karsten Hopp 2d4727
  OutputWrite(PyObject *self, PyObject *args)
Karsten Hopp 2d4727
  {
Karsten Hopp 2d4727
!     Py_ssize_t len;
Karsten Hopp 2d4727
      char *str = NULL;
Karsten Hopp 2d4727
      int error = ((OutputObject *)(self))->error;
Karsten Hopp 2d4727
  
Karsten Hopp 2d4727
--- 74,80 ----
Karsten Hopp 2d4727
      static PyObject *
Karsten Hopp 2d4727
  OutputWrite(PyObject *self, PyObject *args)
Karsten Hopp 2d4727
  {
Karsten Hopp 2d4727
!     Py_ssize_t len = 0;
Karsten Hopp 2d4727
      char *str = NULL;
Karsten Hopp 2d4727
      int error = ((OutputObject *)(self))->error;
Karsten Hopp 2d4727
  
Karsten Hopp 2d4727
*** ../vim-7.3.660/src/if_python.c	2012-09-05 19:03:51.000000000 +0200
Karsten Hopp 2d4727
--- src/if_python.c	2012-09-12 19:52:10.000000000 +0200
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 44,51 ****
Karsten Hopp 2d4727
  # undef _XOPEN_SOURCE	/* pyconfig.h defines it as well. */
Karsten Hopp 2d4727
  #endif
Karsten Hopp 2d4727
  
Karsten Hopp 2d4727
- #define PY_SSIZE_T_CLEAN
Karsten Hopp 2d4727
- 
Karsten Hopp 2d4727
  #include <Python.h>
Karsten Hopp 2d4727
  #if defined(MACOS) && !defined(MACOS_X_UNIX)
Karsten Hopp 2d4727
  # include "macglue.h"
Karsten Hopp 2d4727
--- 44,49 ----
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 54,59 ****
Karsten Hopp 2d4727
--- 52,61 ----
Karsten Hopp 2d4727
  #undef main /* Defined in python.h - aargh */
Karsten Hopp 2d4727
  #undef HAVE_FCNTL_H /* Clash with os_win32.h */
Karsten Hopp 2d4727
  
Karsten Hopp 2d4727
+ #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000
Karsten Hopp 2d4727
+ # define PY_SSIZE_T_CLEAN
Karsten Hopp 2d4727
+ #endif
Karsten Hopp 2d4727
+ 
Karsten Hopp 2d4727
  static void init_structs(void);
Karsten Hopp 2d4727
  
Karsten Hopp 2d4727
  #define PyBytes_FromString PyString_FromString
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 358,365 ****
Karsten Hopp 2d4727
--- 360,374 ----
Karsten Hopp 2d4727
      PYTHON_PROC *ptr;
Karsten Hopp 2d4727
  } python_funcname_table[] =
Karsten Hopp 2d4727
  {
Karsten Hopp 2d4727
+ #ifndef PY_SSIZE_T_CLEAN
Karsten Hopp 2d4727
      {"PyArg_Parse", (PYTHON_PROC*)&dll_PyArg_Parse},
Karsten Hopp 2d4727
      {"PyArg_ParseTuple", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
Karsten Hopp 2d4727
+     {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue},
Karsten Hopp 2d4727
+ #else
Karsten Hopp 2d4727
+     {"_PyArg_Parse_SizeT", (PYTHON_PROC*)&dll_PyArg_Parse},
Karsten Hopp 2d4727
+     {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&dll_PyArg_ParseTuple},
Karsten Hopp 2d4727
+     {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&dll_Py_BuildValue},
Karsten Hopp 2d4727
+ #endif
Karsten Hopp 2d4727
      {"PyMem_Free", (PYTHON_PROC*)&dll_PyMem_Free},
Karsten Hopp 2d4727
      {"PyMem_Malloc", (PYTHON_PROC*)&dll_PyMem_Malloc},
Karsten Hopp 2d4727
      {"PyDict_SetItemString", (PYTHON_PROC*)&dll_PyDict_SetItemString},
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 422,428 ****
Karsten Hopp 2d4727
      {"PySys_SetArgv", (PYTHON_PROC*)&dll_PySys_SetArgv},
Karsten Hopp 2d4727
      {"PyType_Type", (PYTHON_PROC*)&dll_PyType_Type},
Karsten Hopp 2d4727
      {"PyType_Ready", (PYTHON_PROC*)&dll_PyType_Ready},
Karsten Hopp 2d4727
-     {"Py_BuildValue", (PYTHON_PROC*)&dll_Py_BuildValue},
Karsten Hopp 2d4727
      {"Py_FindMethod", (PYTHON_PROC*)&dll_Py_FindMethod},
Karsten Hopp 2d4727
  # if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000 \
Karsten Hopp 2d4727
  	&& SIZEOF_SIZE_T != SIZEOF_INT
Karsten Hopp 2d4727
--- 431,436 ----
Karsten Hopp 2d4727
*** ../vim-7.3.660/src/if_python3.c	2012-09-05 19:09:06.000000000 +0200
Karsten Hopp 2d4727
--- src/if_python3.c	2012-09-12 19:52:10.000000000 +0200
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 42,49 ****
Karsten Hopp 2d4727
  # undef _DEBUG
Karsten Hopp 2d4727
  #endif
Karsten Hopp 2d4727
  
Karsten Hopp 2d4727
- #define PY_SSIZE_T_CLEAN
Karsten Hopp 2d4727
- 
Karsten Hopp 2d4727
  #ifdef F_BLANK
Karsten Hopp 2d4727
  # undef F_BLANK
Karsten Hopp 2d4727
  #endif
Karsten Hopp 2d4727
--- 42,47 ----
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 66,71 ****
Karsten Hopp 2d4727
--- 64,73 ----
Karsten Hopp 2d4727
  #undef main /* Defined in python.h - aargh */
Karsten Hopp 2d4727
  #undef HAVE_FCNTL_H /* Clash with os_win32.h */
Karsten Hopp 2d4727
  
Karsten Hopp 2d4727
+ #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000
Karsten Hopp 2d4727
+ # define PY_SSIZE_T_CLEAN
Karsten Hopp 2d4727
+ #endif
Karsten Hopp 2d4727
+ 
Karsten Hopp 2d4727
  static void init_structs(void);
Karsten Hopp 2d4727
  
Karsten Hopp 2d4727
  /* The "surrogateescape" error handler is new in Python 3.1 */
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 328,334 ****
Karsten Hopp 2d4727
--- 330,342 ----
Karsten Hopp 2d4727
      {"PySys_SetArgv", (PYTHON_PROC*)&py3_PySys_SetArgv},
Karsten Hopp 2d4727
      {"Py_SetPythonHome", (PYTHON_PROC*)&py3_Py_SetPythonHome},
Karsten Hopp 2d4727
      {"Py_Initialize", (PYTHON_PROC*)&py3_Py_Initialize},
Karsten Hopp 2d4727
+ #ifndef PY_SSIZE_T_CLEAN
Karsten Hopp 2d4727
      {"PyArg_ParseTuple", (PYTHON_PROC*)&py3_PyArg_ParseTuple},
Karsten Hopp 2d4727
+     {"Py_BuildValue", (PYTHON_PROC*)&py3_Py_BuildValue},
Karsten Hopp 2d4727
+ #else
Karsten Hopp 2d4727
+     {"_PyArg_ParseTuple_SizeT", (PYTHON_PROC*)&py3_PyArg_ParseTuple},
Karsten Hopp 2d4727
+     {"_Py_BuildValue_SizeT", (PYTHON_PROC*)&py3_Py_BuildValue},
Karsten Hopp 2d4727
+ #endif
Karsten Hopp 2d4727
      {"PyMem_Free", (PYTHON_PROC*)&py3_PyMem_Free},
Karsten Hopp 2d4727
      {"PyMem_Malloc", (PYTHON_PROC*)&py3_PyMem_Malloc},
Karsten Hopp 2d4727
      {"PyList_New", (PYTHON_PROC*)&py3_PyList_New},
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 364,370 ****
Karsten Hopp 2d4727
      {"PyObject_GetIter", (PYTHON_PROC*)&py3_PyObject_GetIter},
Karsten Hopp 2d4727
      {"PyLong_FromLong", (PYTHON_PROC*)&py3_PyLong_FromLong},
Karsten Hopp 2d4727
      {"PyDict_New", (PYTHON_PROC*)&py3_PyDict_New},
Karsten Hopp 2d4727
-     {"Py_BuildValue", (PYTHON_PROC*)&py3_Py_BuildValue},
Karsten Hopp 2d4727
      {"PyType_Ready", (PYTHON_PROC*)&py3_PyType_Ready},
Karsten Hopp 2d4727
      {"PyDict_SetItemString", (PYTHON_PROC*)&py3_PyDict_SetItemString},
Karsten Hopp 2d4727
      {"PyLong_AsLong", (PYTHON_PROC*)&py3_PyLong_AsLong},
Karsten Hopp 2d4727
--- 372,377 ----
Karsten Hopp 2d4727
*** ../vim-7.3.660/src/version.c	2012-09-12 18:19:39.000000000 +0200
Karsten Hopp 2d4727
--- src/version.c	2012-09-12 19:53:52.000000000 +0200
Karsten Hopp 2d4727
***************
Karsten Hopp 2d4727
*** 721,722 ****
Karsten Hopp 2d4727
--- 721,724 ----
Karsten Hopp 2d4727
  {   /* Add new patch number below this line */
Karsten Hopp 2d4727
+ /**/
Karsten Hopp 2d4727
+     661,
Karsten Hopp 2d4727
  /**/
Karsten Hopp 2d4727
Karsten Hopp 2d4727
-- 
Karsten Hopp 2d4727
Courtroom Quote #19:
Karsten Hopp 2d4727
Q:  Doctor, how many autopsies have you performed on dead people?
Karsten Hopp 2d4727
A:  All my autopsies have been performed on dead people.
Karsten Hopp 2d4727
Karsten Hopp 2d4727
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 2d4727
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 2d4727
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 2d4727
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///