[Python-3000-checkins] r58346 - python/branches/py3k/Modules/_bsddb.c

gregory.p.smith python-3000-checkins at python.org
Sat Oct 6 10:22:26 CEST 2007


Author: gregory.p.smith
Date: Sat Oct  6 10:22:26 2007
New Revision: 58346

Modified:
   python/branches/py3k/Modules/_bsddb.c
Log:
Merge 58343: attempt to fix DBSequence.get_key() to not fail or crash.


Modified: python/branches/py3k/Modules/_bsddb.c
==============================================================================
--- python/branches/py3k/Modules/_bsddb.c	(original)
+++ python/branches/py3k/Modules/_bsddb.c	Sat Oct  6 10:22:26 2007
@@ -5024,14 +5024,20 @@
 {
     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*


More information about the Python-3000-checkins mailing list