8000 Be more safer · python/cpython@9cfd667 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9cfd667

Browse files
committed
Be more safer
1 parent ae3e1e5 commit 9cfd667

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Modules/_dbmmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ _dbm_dbm_clear_impl(dbmobject *self, PyTypeObject *cls)
429429
_dbm_state *state = PyType_GetModuleState(cls);
430430
assert(state != NULL);
431431
check_dbmobject_open(self, state->dbm_error);
432-
for (datum key = dbm_firstkey(self->di_dbm); key.dptr; key = dbm_nextkey(self->di_dbm)) {
432+
datum key;
433+
while (key = dbm_firstkey(self->di_dbm), key.dptr) {
433434
if (dbm_delete(self->di_dbm, key) < 0) {
434435
dbm_clearerr(self->di_dbm);
435436
PyErr_SetString(state->dbm_error, "cannot delete item from database");

0 commit comments

Comments
 (0)
0