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.1069 < prev    next >
Encoding:
Internet Message Format  |  2013-05-29  |  4.5 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.1069
  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.1069
  11. Problem:    Python: memory leaks.
  12. Solution:   Python patch 28: Purge out DICTKEY_CHECK_EMPTY macros. (ZyX)
  13. Files:        src/if_py_both.h
  14.  
  15.  
  16. *** ../vim-7.3.1068/src/if_py_both.h    2013-05-30 13:37:23.000000000 +0200
  17. --- src/if_py_both.h    2013-05-30 14:50:11.000000000 +0200
  18. ***************
  19. *** 32,46 ****
  20.   
  21.   #define DICTKEY_DECL \
  22.       PyObject    *dictkey_todecref = NULL;
  23. - #define DICTKEY_CHECK_EMPTY(err) \
  24. -     if (*key == NUL) \
  25. -     { \
  26. -     PyErr_SetString(PyExc_ValueError, _("empty keys are not allowed")); \
  27. -     return err; \
  28. -     }
  29. - #define DICTKEY_SET_KEY (key = StringToChars(keyObject, &dictkey_todecref))
  30.   #define DICTKEY_GET(err, decref) \
  31. !     if (!DICTKEY_SET_KEY) \
  32.       { \
  33.       if (decref) \
  34.       { \
  35. --- 32,39 ----
  36.   
  37.   #define DICTKEY_DECL \
  38.       PyObject    *dictkey_todecref = NULL;
  39.   #define DICTKEY_GET(err, decref) \
  40. !     if (!(key = StringToChars(keyObject, &dictkey_todecref))) \
  41.       { \
  42.       if (decref) \
  43.       { \
  44. ***************
  45. *** 50,56 ****
  46.       } \
  47.       if (decref && !dictkey_todecref) \
  48.       dictkey_todecref = keyObject; \
  49. !     DICTKEY_CHECK_EMPTY(err)
  50.   #define DICTKEY_UNREF \
  51.       Py_XDECREF(dictkey_todecref);
  52.   
  53. --- 43,53 ----
  54.       } \
  55.       if (decref && !dictkey_todecref) \
  56.       dictkey_todecref = keyObject; \
  57. !     if (*key == NUL) \
  58. !     { \
  59. !     PyErr_SetString(PyExc_ValueError, _("empty keys are not allowed")); \
  60. !     return err; \
  61. !     }
  62.   #define DICTKEY_UNREF \
  63.       Py_XDECREF(dictkey_todecref);
  64.   
  65. ***************
  66. *** 4551,4557 ****
  67.   
  68.       while (PyDict_Next(obj, &iter, &keyObject, &valObject))
  69.       {
  70. !     DICTKEY_DECL
  71.   
  72.       if (keyObject == NULL || valObject == NULL)
  73.       {
  74. --- 4548,4554 ----
  75.   
  76.       while (PyDict_Next(obj, &iter, &keyObject, &valObject))
  77.       {
  78. !     PyObject    *todecref = NULL;
  79.   
  80.       if (keyObject == NULL || valObject == NULL)
  81.       {
  82. ***************
  83. *** 4559,4574 ****
  84.           return -1;
  85.       }
  86.   
  87. !     if (!DICTKEY_SET_KEY)
  88.       {
  89.           dict_unref(dict);
  90.           return -1;
  91.       }
  92. -     DICTKEY_CHECK_EMPTY(-1)
  93.   
  94.       di = dictitem_alloc(key);
  95.   
  96. !     DICTKEY_UNREF
  97.   
  98.       if (di == NULL)
  99.       {
  100. --- 4556,4576 ----
  101.           return -1;
  102.       }
  103.   
  104. !     if (!(key = StringToChars(keyObject, &todecref)))
  105. !     {
  106. !         dict_unref(dict);
  107. !         return -1;
  108. !     }
  109. !     if (*key == NUL)
  110.       {
  111.           dict_unref(dict);
  112. +         Py_XDECREF(todecref);
  113.           return -1;
  114.       }
  115.   
  116.       di = dictitem_alloc(key);
  117.   
  118. !     Py_XDECREF(todecref);
  119.   
  120.       if (di == NULL)
  121.       {
  122. ***************
  123. *** 4632,4662 ****
  124.   
  125.       while ((keyObject = PyIter_Next(iterator)))
  126.       {
  127. !     DICTKEY_DECL
  128.   
  129. !     if (!DICTKEY_SET_KEY)
  130.       {
  131.           Py_DECREF(iterator);
  132.           dict_unref(dict);
  133. -         DICTKEY_UNREF
  134.           return -1;
  135.       }
  136. !     DICTKEY_CHECK_EMPTY(-1)
  137.   
  138.       if (!(valObject = PyObject_GetItem(obj, keyObject)))
  139.       {
  140.           Py_DECREF(keyObject);
  141.           Py_DECREF(iterator);
  142.           dict_unref(dict);
  143. -         DICTKEY_UNREF
  144.           return -1;
  145.       }
  146.   
  147.       di = dictitem_alloc(key);
  148.   
  149. -     DICTKEY_UNREF
  150.       Py_DECREF(keyObject);
  151.   
  152.       if (di == NULL)
  153.       {
  154. --- 4634,4670 ----
  155.   
  156.       while ((keyObject = PyIter_Next(iterator)))
  157.       {
  158. !     PyObject    *todecref;
  159.   
  160. !     if (!(key = StringToChars(keyObject, &todecref)))
  161.       {
  162. +         Py_DECREF(keyObject);
  163.           Py_DECREF(iterator);
  164.           dict_unref(dict);
  165.           return -1;
  166.       }
  167. !     if (*key == NUL)
  168. !     {
  169. !         Py_DECREF(keyObject);
  170. !         Py_DECREF(iterator);
  171. !         Py_XDECREF(todecref);
  172. !         dict_unref(dict);
  173. !         return -1;
  174. !     }
  175.   
  176.       if (!(valObject = PyObject_GetItem(obj, keyObject)))
  177.       {
  178.           Py_DECREF(keyObject);
  179.           Py_DECREF(iterator);
  180. +         Py_XDECREF(todecref);
  181.           dict_unref(dict);
  182.           return -1;
  183.       }
  184.   
  185.       di = dictitem_alloc(key);
  186.   
  187.       Py_DECREF(keyObject);
  188. +     Py_XDECREF(todecref);
  189.   
  190.       if (di == NULL)
  191.       {
  192. *** ../vim-7.3.1068/src/version.c    2013-05-30 13:37:23.000000000 +0200
  193. --- src/version.c    2013-05-30 13:38:46.000000000 +0200
  194. ***************
  195. *** 730,731 ****
  196. --- 730,733 ----
  197.   {   /* Add new patch number below this line */
  198. + /**/
  199. +     1069,
  200.   /**/
  201.  
  202. -- 
  203. How To Keep A Healthy Level Of Insanity:
  204. 11. Specify that your drive-through order is "to go".
  205.  
  206.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  207. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  208. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  209.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  210.