home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.1041 < prev    next >
Encoding:
Internet Message Format  |  2013-05-28  |  3.9 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.1041
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.1041
  11. Problem:    Python: Invalid read valgrind errors.
  12. Solution:   Python patch 2: defer DICTKEY_UNREF until key is no longer needed.
  13.         (ZyX)
  14. Files:        src/if_py_both.h
  15.  
  16.  
  17. *** ../vim-7.3.1040/src/if_py_both.h    2013-05-28 22:31:43.000000000 +0200
  18. --- src/if_py_both.h    2013-05-29 21:36:29.000000000 +0200
  19. ***************
  20. *** 1603,1613 ****
  21.       flags = get_option_value_strict(key, NULL, NULL,
  22.                       self->opt_type, self->from);
  23.   
  24. -     DICTKEY_UNREF
  25.       if (flags == 0)
  26.       {
  27.       PyErr_SetObject(PyExc_KeyError, keyObject);
  28.       return -1;
  29.       }
  30.   
  31. --- 1603,1612 ----
  32.       flags = get_option_value_strict(key, NULL, NULL,
  33.                       self->opt_type, self->from);
  34.   
  35.       if (flags == 0)
  36.       {
  37.       PyErr_SetObject(PyExc_KeyError, keyObject);
  38. +     DICTKEY_UNREF
  39.       return -1;
  40.       }
  41.   
  42. ***************
  43. *** 1617,1633 ****
  44. --- 1616,1635 ----
  45.       {
  46.           PyErr_SetString(PyExc_ValueError,
  47.               _("unable to unset global option"));
  48. +         DICTKEY_UNREF
  49.           return -1;
  50.       }
  51.       else if (!(flags & SOPT_GLOBAL))
  52.       {
  53.           PyErr_SetString(PyExc_ValueError, _("unable to unset option "
  54.                           "without global value"));
  55. +         DICTKEY_UNREF
  56.           return -1;
  57.       }
  58.       else
  59.       {
  60.           unset_global_local_option(key, self->from);
  61. +         DICTKEY_UNREF
  62.           return 0;
  63.       }
  64.       }
  65. ***************
  66. *** 1639,1647 ****
  67.       int    istrue = PyObject_IsTrue(valObject);
  68.   
  69.       if (istrue == -1)
  70. !         return -1;
  71. !     r = set_option_value_for(key, istrue, NULL,
  72. !                 opt_flags, self->opt_type, self->from);
  73.       }
  74.       else if (flags & SOPT_NUM)
  75.       {
  76. --- 1641,1650 ----
  77.       int    istrue = PyObject_IsTrue(valObject);
  78.   
  79.       if (istrue == -1)
  80. !         r = -1;
  81. !     else
  82. !         r = set_option_value_for(key, istrue, NULL,
  83. !                     opt_flags, self->opt_type, self->from);
  84.       }
  85.       else if (flags & SOPT_NUM)
  86.       {
  87. ***************
  88. *** 1657,1662 ****
  89. --- 1660,1666 ----
  90.       else
  91.       {
  92.           PyErr_SetString(PyExc_TypeError, _("object must be integer"));
  93. +         DICTKEY_UNREF
  94.           return -1;
  95.       }
  96.   
  97. ***************
  98. *** 1670,1678 ****
  99. --- 1674,1688 ----
  100.       {
  101.   
  102.           if (PyString_AsStringAndSize(valObject, (char **) &val, NULL) == -1)
  103. +         {
  104. +         DICTKEY_UNREF
  105.           return -1;
  106. +         }
  107.           if (val == NULL)
  108. +         {
  109. +         DICTKEY_UNREF
  110.           return -1;
  111. +         }
  112.   
  113.           val = vim_strsave(val);
  114.       }
  115. ***************
  116. *** 1682,1693 ****
  117. --- 1692,1712 ----
  118.   
  119.           bytes = PyUnicode_AsEncodedString(valObject, (char *)ENC_OPT, NULL);
  120.           if (bytes == NULL)
  121. +         {
  122. +         DICTKEY_UNREF
  123.           return -1;
  124. +         }
  125.   
  126.           if(PyString_AsStringAndSize(bytes, (char **) &val, NULL) == -1)
  127. +         {
  128. +         DICTKEY_UNREF
  129.           return -1;
  130. +         }
  131.           if (val == NULL)
  132. +         {
  133. +         DICTKEY_UNREF
  134.           return -1;
  135. +         }
  136.   
  137.           val = vim_strsave(val);
  138.           Py_XDECREF(bytes);
  139. ***************
  140. *** 1695,1700 ****
  141. --- 1714,1720 ----
  142.       else
  143.       {
  144.           PyErr_SetString(PyExc_TypeError, _("object must be string"));
  145. +         DICTKEY_UNREF
  146.           return -1;
  147.       }
  148.   
  149. ***************
  150. *** 1703,1708 ****
  151. --- 1723,1730 ----
  152.       vim_free(val);
  153.       }
  154.   
  155. +     DICTKEY_UNREF
  156.       return r;
  157.   }
  158.   
  159. *** ../vim-7.3.1040/src/version.c    2013-05-29 21:33:34.000000000 +0200
  160. --- src/version.c    2013-05-29 21:36:47.000000000 +0200
  161. ***************
  162. *** 730,731 ****
  163. --- 730,733 ----
  164.   {   /* Add new patch number below this line */
  165. + /**/
  166. +     1041,
  167.   /**/
  168.  
  169. -- 
  170. hundred-and-one symptoms of being an internet addict:
  171. 18. Your wife drapes a blond wig over your monitor to remind you of what she
  172.     looks like.
  173.  
  174.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  175. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  176. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  177.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  178.