[Python-checkins] r58350 - python/branches/release25-maint/Modules/_bsddb.c

gregory.p.smith python-checkins at python.org
Sat Oct 6 18:05:18 CEST 2007


Author: gregory.p.smith
Date: Sat Oct  6 18:05:18 2007
New Revision: 58350

Modified:
   python/branches/release25-maint/Modules/_bsddb.c
Log:
Backport rev 58343: fix DBSequence.get_key() to not crash/fail/etc.


Modified: python/branches/release25-maint/Modules/_bsddb.c
==============================================================================
--- python/branches/release25-maint/Modules/_bsddb.c	(original)
+++ python/branches/release25-maint/Modules/_bsddb.c	Sat Oct  6 18:05:18 2007
@@ -4883,14 +4883,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 = PyString_FromStringAndSize(key.data, key.size); 
+
+    FREE_DBT(key);
     RETURN_IF_ERR();
 
-    return PyString_FromStringAndSize(key.data, key.size);
+    return retval;
 }
 
 static PyObject*


More information about the Python-checkins mailing list