diff options
Diffstat (limited to 'Modules/_bsddb.c')
-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 f9bc253..d03f72b 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -335,11 +335,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); } @@ -5795,6 +5797,10 @@ DL_EXPORT(void) init_bsddb(void) ADD_INT(d, DB_NOPANIC); #endif +#ifdef DB_REGISTER + ADD_INT(d, DB_REGISTER); +#endif + #if (DBVER >= 42) ADD_INT(d, DB_TIME_NOTGRANTED); ADD_INT(d, DB_TXN_NOT_DURABLE); |