Skip to content

Commit

Permalink
Be more safer
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Jul 23, 2023
1 parent ae3e1e5 commit 9cfd667
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Modules/_dbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ _dbm_dbm_clear_impl(dbmobject *self, PyTypeObject *cls)
_dbm_state *state = PyType_GetModuleState(cls);
assert(state != NULL);
check_dbmobject_open(self, state->dbm_error);
for (datum key = dbm_firstkey(self->di_dbm); key.dptr; key = dbm_nextkey(self->di_dbm)) {
datum key;
while (key = dbm_firstkey(self->di_dbm), key.dptr) {
if (dbm_delete(self->di_dbm, key) < 0) {
dbm_clearerr(self->di_dbm);
PyErr_SetString(state->dbm_error, "cannot delete item from database");
Expand Down

0 comments on commit 9cfd667

Please sign in to comment.