diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2007-10-06 08:22:26 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2007-10-06 08:22:26 (GMT) |
commit | 9e780cc4e7466fdaf657633eabbc69974949be32 (patch) | |
tree | a5506219c4776480f7e42c1835eb81612281c891 | |
parent | 1d2aef5ccf1a46ce73bf4f0c7da91e45a091a87c (diff) | |
download | cpython-9e780cc4e7466fdaf657633eabbc69974949be32.zip cpython-9e780cc4e7466fdaf657633eabbc69974949be32.tar.gz cpython-9e780cc4e7466fdaf657633eabbc69974949be32.tar.bz2 |
Merge 58343: attempt to fix DBSequence.get_key() to not fail or crash.
-rw-r--r-- | Modules/_bsddb.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index 6f323d5..175dec3 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -5024,14 +5024,20 @@ DBSequence_get_key(DBSequenceObject* self, PyObject* args) { int err; DBT key; + PyObject *retval; + key.flags = DB_DBT_MALLOC; CHECK_SEQUENCE_NOT_CLOSED(self) MYDB_BEGIN_ALLOW_THREADS err = self->sequence->get_key(self->sequence, &key); MYDB_END_ALLOW_THREADS + if (!err) + retval = PyBytes_FromStringAndSize(key.data, key.size); + + free_dbt(&key); RETURN_IF_ERR(); - return PyBytes_FromStringAndSize(key.data, key.size); + return retval; } static PyObject* |