X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fdatabase.c;fp=citadel%2Fdatabase.c;h=37a9d79745f59ec0902951d757f2ab2e41cb17c5;hb=2b5449a35c6ae9b76bee5bb1b2fe0f5e17393c38;hp=dfeb4f013946cb1c4f9c1cda84f2a8143c7b192a;hpb=d68abff5fe1d3d42d1d3ac6ad612ecb68429b3db;p=citadel.git diff --git a/citadel/database.c b/citadel/database.c index dfeb4f013..37a9d7974 100644 --- a/citadel/database.c +++ b/citadel/database.c @@ -32,7 +32,6 @@ #include #include #include - #include #if DB_VERSION_MAJOR < 5 @@ -548,6 +547,13 @@ static DBC *localcursor(int cdb) { * using the cdb_free() routine. */ struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen) { + + syslog(LOG_DEBUG, "\x1b[35mdatabase: fetch from db %d a key of length %d\x1b[0m", cdb, keylen); + + if (keylen == 0) { + abort(); + } + struct cdbdata *tempcdb; DBT dkey, dret; int ret; @@ -559,8 +565,9 @@ struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen) { if (TSD->tid != NULL) { memset(&dret, 0, sizeof(DBT)); dret.flags = DB_DBT_MALLOC; - ret = dbp[cdb]->get(dbp[cdb], TSD->tid, &dkey, &dret, 0); // crashing here - } else { + ret = dbp[cdb]->get(dbp[cdb], TSD->tid, &dkey, &dret, 0); + } + else { DBC *curs; do { @@ -588,7 +595,8 @@ struct cdbdata *cdb_fetch(int cdb, const void *key, int keylen) { syslog(LOG_ERR, "db: cdb_fetch: Cannot allocate memory for tempcdb"); cdb_abort(); return NULL; /* make it easier for static analysis... */ - } else { + } + else { tempcdb->len = dret.size; tempcdb->ptr = dret.data; cdb_decompress_if_necessary(tempcdb);