Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e780cc

Browse files
committed
Merge 58343: attempt to fix DBSequence.get_key() to not fail or crash.
1 parent 1d2aef5 commit 9e780cc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Modules/_bsddb.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5024,14 +5024,20 @@ DBSequence_get_key(DBSequenceObject* self, PyObject* args)
50245024
{
50255025
int err;
50265026
DBT key;
5027+
PyObject *retval;
5028+
key.flags = DB_DBT_MALLOC;
50275029
CHECK_SEQUENCE_NOT_CLOSED(self)
50285030
MYDB_BEGIN_ALLOW_THREADS
50295031
err = self->sequence->get_key(self->sequence, &key);
50305032
MYDB_END_ALLOW_THREADS
50315033

5034+
if (!err)
5035+
retval = PyBytes_FromStringAndSize(key.data, key.size);
5036+
5037+
free_dbt(&key);
50325038
RETURN_IF_ERR();
50335039

5034-
return PyBytes_FromStringAndSize(key.data, key.size);
5040+
return retval;
50355041
}
50365042

50375043
static PyObject*

0 commit comments

Comments
 (0)