Skip to content

Commit 0231a39

Browse files
[3.13] pythongh-140272: Fix memory leak in _gdbm.gdbm.clear() (pythonGH-140274) (pythonGH-140289)
(cherry picked from commit f937468) Co-authored-by: Shamil <[email protected]>
1 parent 0760a57 commit 0231a39

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix memory leak in the :meth:`!clear` method of the :mod:`dbm.gnu` database.

Modules/_gdbmmodule.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,10 @@ _gdbm_gdbm_clear_impl(gdbmobject *self, PyTypeObject *cls)
612612
}
613613
if (gdbm_delete(self->di_dbm, key) < 0) {
614614
PyErr_SetString(state->gdbm_error, "cannot delete item from database");
615+
free(key.dptr);
615616
return NULL;
616617
}
618+
free(key.dptr);
617619
}
618620
Py_RETURN_NONE;
619621
}

0 commit comments

Comments
 (0)