Skip to content

Commit

Permalink
updated for version 7.3.670
Browse files Browse the repository at this point in the history
Problem:    Python: memory leaks when there are exceptions.
Solution:   Add DICTKEY_UNREF in the right places. (ZyX)
  • Loading branch information
brammool committed Sep 21, 2012
1 parent f94a13c commit 696c211
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/if_py_both.h
Expand Up @@ -799,14 +799,14 @@ DictionaryItem(PyObject *self, PyObject *keyObject)


di = dict_find(((DictionaryObject *) (self))->dict, key, -1); di = dict_find(((DictionaryObject *) (self))->dict, key, -1);


DICTKEY_UNREF

if (di == NULL) if (di == NULL)
{ {
PyErr_SetString(PyExc_IndexError, _("no such key in dictionary")); PyErr_SetString(PyExc_IndexError, _("no such key in dictionary"));
return NULL; return NULL;
} }


DICTKEY_UNREF

return ConvertToPyObject(&di->di_tv); return ConvertToPyObject(&di->di_tv);
} }


Expand Down Expand Up @@ -835,6 +835,7 @@ DictionaryAssItem(PyObject *self, PyObject *keyObject, PyObject *valObject)


if (di == NULL) if (di == NULL)
{ {
DICTKEY_UNREF
PyErr_SetString(PyExc_IndexError, _("no such key in dictionary")); PyErr_SetString(PyExc_IndexError, _("no such key in dictionary"));
return -1; return -1;
} }
Expand All @@ -859,6 +860,7 @@ DictionaryAssItem(PyObject *self, PyObject *keyObject, PyObject *valObject)


if (dict_add(d, di) == FAIL) if (dict_add(d, di) == FAIL)
{ {
DICTKEY_UNREF
vim_free(di); vim_free(di);
PyErr_SetVim(_("failed to add key to dictionary")); PyErr_SetVim(_("failed to add key to dictionary"));
return -1; return -1;
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -719,6 +719,8 @@ static char *(features[]) =


static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
670,
/**/ /**/
669, 669,
/**/ /**/
Expand Down

0 comments on commit 696c211

Please sign in to comment.