Skip to content

Commit 80ac19c

Browse files
authored
Fix #307: memory leak in __len__ and __contains__ view implementation (#309)
1 parent 2e183f8 commit 80ac19c

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

docs/changes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
.. _changes:
22

3+
4.5.2 (2018-11-28)
4+
------------------
5+
6+
* Fix another memory leak introduced by 4.5.0 release (:pr:`307`)
7+
38
4.5.1 (2018-11-22)
49
------------------
510

multidict/_multidict_views.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ multidict_view_clear(_Multidict_ViewObject *self)
8484
static Py_ssize_t
8585
multidict_view_len(_Multidict_ViewObject *self)
8686
{
87+
Py_ssize_t ret;
8788
PyObject *impl = _PyObject_CallMethodId(self->md, &PyId_impl, NULL);
8889
if (impl == NULL) {
8990
return 0;
9091
}
91-
return pair_list_len(impl);
92+
ret = pair_list_len(impl);
93+
Py_DECREF(impl);
94+
return ret;
9295
}
9396

9497
static PyObject *
@@ -374,11 +377,14 @@ static PyMethodDef multidict_keysview_methods[] = {
374377
static int
375378
multidict_keysview_contains(_Multidict_ViewObject *self, PyObject *key)
376379
{
380+
int ret;
377381
PyObject *impl = _PyObject_CallMethodId(self->md, &PyId_impl, NULL);
378382
if (impl == NULL) {
379383
return -1;
380384
}
381-
return pair_list_contains(impl, key);
385+
ret = pair_list_contains(impl, key);
386+
Py_DECREF(impl);
387+
return ret;
382388
}
383389

384390
static PySequenceMethods multidict_keysview_as_sequence = {

requirements/wheel.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cython==0.29
1+
cython==0.29.1
22
pytest==4.0.0
33
pytest-cov==2.6.0
44

0 commit comments

Comments
 (0)