Skip to content

Commit 128f48f

Browse files
[3.14] gh-140272: Fix memory leak in _gdbm.gdbm.clear() (GH-140274) (GH-140285)
(cherry picked from commit f937468) Co-authored-by: Shamil <ashm.tech@proton.me>
1 parent f59236b commit 128f48f

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
@@ -678,8 +678,10 @@ _gdbm_gdbm_clear_impl(gdbmobject *self, PyTypeObject *cls)
678678
}
679679
if (gdbm_delete(self->di_dbm, key) < 0) {
680680
PyErr_SetString(state->gdbm_error, "cannot delete item from database");
681+
free(key.dptr);
681682
return NULL;
682683
}
684+
free(key.dptr);
683685
}
684686
Py_RETURN_NONE;
685687
}

0 commit comments

Comments
 (0)