Skip to content

Commit c02d2db

Browse files
committed
fix reference leak in count_nextlong
1 parent 7015ae6 commit c02d2db

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Modules/itertoolsmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3538,9 +3538,10 @@ count_nextlong(countobject *lz)
35383538
if (long_cnt == NULL) {
35393539
/* Switch to slow_mode */
35403540
long_cnt = PyLong_FromSsize_t(PY_SSIZE_T_MAX);
3541-
lz->long_cnt = long_cnt;
3542-
if (long_cnt == NULL)
3541+
if (long_cnt == NULL) {
35433542
return NULL;
3543+
}
3544+
lz->long_cnt = long_cnt;
35443545
}
35453546
assert(lz->cnt == PY_SSIZE_T_MAX && long_cnt != NULL);
35463547

Objects/enumobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ increment_longindex_lock_held(enumobject *en)
184184
if (next_index == NULL) {
185185
return NULL;
186186
}
187+
en->en_longindex = next_index;
187188
}
188189
assert(next_index != NULL);
189190
PyObject *stepped_up = PyNumber_Add(next_index, en->one);
190191
if (stepped_up == NULL) {
191-
Py_DECREF(next_index);
192192
return NULL;
193193
}
194194
en->en_longindex = stepped_up;

0 commit comments

Comments
 (0)