summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2007-11-01 21:22:40 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2007-11-01 21:22:40 (GMT)
commit2c3e0d94b2357d53e3a460dec244b1e98462ede4 (patch)
tree30d81e4d0c4855a927d6a87b05db5cdadfa0a5fd /Modules
parentbf75c5133d61d0c404eddfbfc035829def0af6c0 (diff)
downloadcpython-2c3e0d94b2357d53e3a460dec244b1e98462ede4.zip
cpython-2c3e0d94b2357d53e3a460dec244b1e98462ede4.tar.gz
cpython-2c3e0d94b2357d53e3a460dec244b1e98462ede4.tar.bz2
Backport r58757, r58758, r58759.
Undoes incorrect dbtables fix and errant strdup introduced as described below: r58757 | gregory.p.smith | 2007-11-01 14:08:14 -0700 (Thu, 01 Nov 2007) | 4 lines Fix bug introduced in revision 58385. Database keys could no longer have NULL bytes in them. Replace the errant strdup with a malloc+memcpy. Adds a unit test for the correct behavior. r58758 | gregory.p.smith | 2007-11-01 14:15:36 -0700 (Thu, 01 Nov 2007) | 3 lines Undo revision 58533 58534 fixes. Those were a workaround for a problem introduced by 58385. r58759 | gregory.p.smith | 2007-11-01 14:17:47 -0700 (Thu, 01 Nov 2007) | 2 lines false "fix" undone as correct problem was found and fixed.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_bsddb.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 195132e..999e302 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -432,11 +432,13 @@ make_key_dbt(DBObject* self, PyObject* keyobj, DBT* key, int* pflags)
* the code check for DB_THREAD and forceably set DBT_MALLOC
* when we otherwise would leave flags 0 to indicate that.
*/
- key->data = strdup(PyString_AS_STRING(keyobj));
+ key->data = malloc(PyString_GET_SIZE(keyobj));
if (key->data == NULL) {
PyErr_SetString(PyExc_MemoryError, "Key memory allocation failed");
return 0;
}
+ memcpy(key->data, PyString_AS_STRING(keyobj),
+ PyString_GET_SIZE(keyobj));
key->flags = DB_DBT_REALLOC;
key->size = PyString_GET_SIZE(keyobj);
}