Karsten Hopp 03507a
To: vim_dev@googlegroups.com
Karsten Hopp 03507a
Subject: Patch 7.3.1041
Karsten Hopp 03507a
Fcc: outbox
Karsten Hopp 03507a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 03507a
Mime-Version: 1.0
Karsten Hopp 03507a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 03507a
Content-Transfer-Encoding: 8bit
Karsten Hopp 03507a
------------
Karsten Hopp 03507a
Karsten Hopp 03507a
Patch 7.3.1041
Karsten Hopp 03507a
Problem:    Python: Invalid read valgrind errors.
Karsten Hopp 03507a
Solution:   Python patch 2: defer DICTKEY_UNREF until key is no longer needed.
Karsten Hopp 03507a
	    (ZyX)
Karsten Hopp 03507a
Files:	    src/if_py_both.h
Karsten Hopp 03507a
Karsten Hopp 03507a
Karsten Hopp 03507a
*** ../vim-7.3.1040/src/if_py_both.h	2013-05-28 22:31:43.000000000 +0200
Karsten Hopp 03507a
--- src/if_py_both.h	2013-05-29 21:36:29.000000000 +0200
Karsten Hopp 03507a
***************
Karsten Hopp 03507a
*** 1603,1613 ****
Karsten Hopp 03507a
      flags = get_option_value_strict(key, NULL, NULL,
Karsten Hopp 03507a
  				    self->opt_type, self->from);
Karsten Hopp 03507a
  
Karsten Hopp 03507a
-     DICTKEY_UNREF
Karsten Hopp 03507a
- 
Karsten Hopp 03507a
      if (flags == 0)
Karsten Hopp 03507a
      {
Karsten Hopp 03507a
  	PyErr_SetObject(PyExc_KeyError, keyObject);
Karsten Hopp 03507a
  	return -1;
Karsten Hopp 03507a
      }
Karsten Hopp 03507a
  
Karsten Hopp 03507a
--- 1603,1612 ----
Karsten Hopp 03507a
      flags = get_option_value_strict(key, NULL, NULL,
Karsten Hopp 03507a
  				    self->opt_type, self->from);
Karsten Hopp 03507a
  
Karsten Hopp 03507a
      if (flags == 0)
Karsten Hopp 03507a
      {
Karsten Hopp 03507a
  	PyErr_SetObject(PyExc_KeyError, keyObject);
Karsten Hopp 03507a
+ 	DICTKEY_UNREF
Karsten Hopp 03507a
  	return -1;
Karsten Hopp 03507a
      }
Karsten Hopp 03507a
  
Karsten Hopp 03507a
***************
Karsten Hopp 03507a
*** 1617,1633 ****
Karsten Hopp 03507a
--- 1616,1635 ----
Karsten Hopp 03507a
  	{
Karsten Hopp 03507a
  	    PyErr_SetString(PyExc_ValueError,
Karsten Hopp 03507a
  		    _("unable to unset global option"));
Karsten Hopp 03507a
+ 	    DICTKEY_UNREF
Karsten Hopp 03507a
  	    return -1;
Karsten Hopp 03507a
  	}
Karsten Hopp 03507a
  	else if (!(flags & SOPT_GLOBAL))
Karsten Hopp 03507a
  	{
Karsten Hopp 03507a
  	    PyErr_SetString(PyExc_ValueError, _("unable to unset option "
Karsten Hopp 03507a
  						"without global value"));
Karsten Hopp 03507a
+ 	    DICTKEY_UNREF
Karsten Hopp 03507a
  	    return -1;
Karsten Hopp 03507a
  	}
Karsten Hopp 03507a
  	else
Karsten Hopp 03507a
  	{
Karsten Hopp 03507a
  	    unset_global_local_option(key, self->from);
Karsten Hopp 03507a
+ 	    DICTKEY_UNREF
Karsten Hopp 03507a
  	    return 0;
Karsten Hopp 03507a
  	}
Karsten Hopp 03507a
      }
Karsten Hopp 03507a
***************
Karsten Hopp 03507a
*** 1639,1647 ****
Karsten Hopp 03507a
  	int	istrue = PyObject_IsTrue(valObject);
Karsten Hopp 03507a
  
Karsten Hopp 03507a
  	if (istrue == -1)
Karsten Hopp 03507a
! 	    return -1;
Karsten Hopp 03507a
! 	r = set_option_value_for(key, istrue, NULL,
Karsten Hopp 03507a
! 				opt_flags, self->opt_type, self->from);
Karsten Hopp 03507a
      }
Karsten Hopp 03507a
      else if (flags & SOPT_NUM)
Karsten Hopp 03507a
      {
Karsten Hopp 03507a
--- 1641,1650 ----
Karsten Hopp 03507a
  	int	istrue = PyObject_IsTrue(valObject);
Karsten Hopp 03507a
  
Karsten Hopp 03507a
  	if (istrue == -1)
Karsten Hopp 03507a
! 	    r = -1;
Karsten Hopp 03507a
! 	else
Karsten Hopp 03507a
! 	    r = set_option_value_for(key, istrue, NULL,
Karsten Hopp 03507a
! 				    opt_flags, self->opt_type, self->from);
Karsten Hopp 03507a
      }
Karsten Hopp 03507a
      else if (flags & SOPT_NUM)
Karsten Hopp 03507a
      {
Karsten Hopp 03507a
***************
Karsten Hopp 03507a
*** 1657,1662 ****
Karsten Hopp 03507a
--- 1660,1666 ----
Karsten Hopp 03507a
  	else
Karsten Hopp 03507a
  	{
Karsten Hopp 03507a
  	    PyErr_SetString(PyExc_TypeError, _("object must be integer"));
Karsten Hopp 03507a
+ 	    DICTKEY_UNREF
Karsten Hopp 03507a
  	    return -1;
Karsten Hopp 03507a
  	}
Karsten Hopp 03507a
  
Karsten Hopp 03507a
***************
Karsten Hopp 03507a
*** 1670,1678 ****
Karsten Hopp 03507a
--- 1674,1688 ----
Karsten Hopp 03507a
  	{
Karsten Hopp 03507a
  
Karsten Hopp 03507a
  	    if (PyString_AsStringAndSize(valObject, (char **) &val, NULL) == -1)
Karsten Hopp 03507a
+ 	    {
Karsten Hopp 03507a
+ 		DICTKEY_UNREF
Karsten Hopp 03507a
  		return -1;
Karsten Hopp 03507a
+ 	    }
Karsten Hopp 03507a
  	    if (val == NULL)
Karsten Hopp 03507a
+ 	    {
Karsten Hopp 03507a
+ 		DICTKEY_UNREF
Karsten Hopp 03507a
  		return -1;
Karsten Hopp 03507a
+ 	    }
Karsten Hopp 03507a
  
Karsten Hopp 03507a
  	    val = vim_strsave(val);
Karsten Hopp 03507a
  	}
Karsten Hopp 03507a
***************
Karsten Hopp 03507a
*** 1682,1693 ****
Karsten Hopp 03507a
--- 1692,1712 ----
Karsten Hopp 03507a
  
Karsten Hopp 03507a
  	    bytes = PyUnicode_AsEncodedString(valObject, (char *)ENC_OPT, NULL);
Karsten Hopp 03507a
  	    if (bytes == NULL)
Karsten Hopp 03507a
+ 	    {
Karsten Hopp 03507a
+ 		DICTKEY_UNREF
Karsten Hopp 03507a
  		return -1;
Karsten Hopp 03507a
+ 	    }
Karsten Hopp 03507a
  
Karsten Hopp 03507a
  	    if(PyString_AsStringAndSize(bytes, (char **) &val, NULL) == -1)
Karsten Hopp 03507a
+ 	    {
Karsten Hopp 03507a
+ 		DICTKEY_UNREF
Karsten Hopp 03507a
  		return -1;
Karsten Hopp 03507a
+ 	    }
Karsten Hopp 03507a
  	    if (val == NULL)
Karsten Hopp 03507a
+ 	    {
Karsten Hopp 03507a
+ 		DICTKEY_UNREF
Karsten Hopp 03507a
  		return -1;
Karsten Hopp 03507a
+ 	    }
Karsten Hopp 03507a
  
Karsten Hopp 03507a
  	    val = vim_strsave(val);
Karsten Hopp 03507a
  	    Py_XDECREF(bytes);
Karsten Hopp 03507a
***************
Karsten Hopp 03507a
*** 1695,1700 ****
Karsten Hopp 03507a
--- 1714,1720 ----
Karsten Hopp 03507a
  	else
Karsten Hopp 03507a
  	{
Karsten Hopp 03507a
  	    PyErr_SetString(PyExc_TypeError, _("object must be string"));
Karsten Hopp 03507a
+ 	    DICTKEY_UNREF
Karsten Hopp 03507a
  	    return -1;
Karsten Hopp 03507a
  	}
Karsten Hopp 03507a
  
Karsten Hopp 03507a
***************
Karsten Hopp 03507a
*** 1703,1708 ****
Karsten Hopp 03507a
--- 1723,1730 ----
Karsten Hopp 03507a
  	vim_free(val);
Karsten Hopp 03507a
      }
Karsten Hopp 03507a
  
Karsten Hopp 03507a
+     DICTKEY_UNREF
Karsten Hopp 03507a
+ 
Karsten Hopp 03507a
      return r;
Karsten Hopp 03507a
  }
Karsten Hopp 03507a
  
Karsten Hopp 03507a
*** ../vim-7.3.1040/src/version.c	2013-05-29 21:33:34.000000000 +0200
Karsten Hopp 03507a
--- src/version.c	2013-05-29 21:36:47.000000000 +0200
Karsten Hopp 03507a
***************
Karsten Hopp 03507a
*** 730,731 ****
Karsten Hopp 03507a
--- 730,733 ----
Karsten Hopp 03507a
  {   /* Add new patch number below this line */
Karsten Hopp 03507a
+ /**/
Karsten Hopp 03507a
+     1041,
Karsten Hopp 03507a
  /**/
Karsten Hopp 03507a
Karsten Hopp 03507a
-- 
Karsten Hopp 03507a
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 03507a
18. Your wife drapes a blond wig over your monitor to remind you of what she
Karsten Hopp 03507a
    looks like.
Karsten Hopp 03507a
Karsten Hopp 03507a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 03507a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 03507a
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 03507a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///