diff src/if_py_both.h @ 4706:bf917ee1fad2 v7.3.1100

updated for version 7.3.1100 Problem: Python: a few more memory problems. Solution: Add and remove Py_XDECREF(). (ZyX)
author Bram Moolenaar <bram@vim.org>
date Sun, 02 Jun 2013 18:54:21 +0200
parents 542af01979be
children 3534e9b4fa42
line wrap: on
line diff
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -1236,6 +1236,7 @@ DictionaryAssItem(DictionaryObject *self
     if (*key == NUL)
     {
 	RAISE_NO_EMPTY_KEYS;
+	Py_XDECREF(todecref);
 	return -1;
     }
 
@@ -1254,11 +1255,15 @@ DictionaryAssItem(DictionaryObject *self
 	hi = hash_find(&dict->dv_hashtab, di->di_key);
 	hash_remove(&dict->dv_hashtab, hi);
 	dictitem_free(di);
+	Py_XDECREF(todecref);
 	return 0;
     }
 
     if (ConvertFromPyObject(valObject, &tv) == -1)
+    {
+	Py_XDECREF(todecref);
 	return -1;
+    }
 
     if (di == NULL)
     {
@@ -2505,11 +2510,8 @@ OptionsAssItem(OptionsObject *self, PyOb
 	PyObject	*todecref;
 
 	if ((val = StringToChars(valObject, &todecref)))
-	{
 	    r = set_option_value_for(key, 0, val, opt_flags,
 				    self->opt_type, self->from);
-	    Py_XDECREF(todecref);
-	}
 	else
 	    r = -1;
     }