mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 15:24:16 +01:00
Don't double free. Addresses #322.
git-svn-id: file:///svn/tokudb@1964 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
28ce4a3b4e
commit
82e195e64d
2 changed files with 6 additions and 6 deletions
|
@ -149,6 +149,8 @@ NO_VGRIND = \
|
||||||
dup_dup \
|
dup_dup \
|
||||||
dup_flags \
|
dup_flags \
|
||||||
dup_insert \
|
dup_insert \
|
||||||
|
dup_next \
|
||||||
|
dup_search \
|
||||||
log4 \
|
log4 \
|
||||||
log5 \
|
log5 \
|
||||||
# Comment to terminate list so the previous line can end with a slash
|
# Comment to terminate list so the previous line can end with a slash
|
||||||
|
|
|
@ -26,8 +26,6 @@ DB_TXN *const null_txn = 0;
|
||||||
DB_ENV *dbenv = 0;
|
DB_ENV *dbenv = 0;
|
||||||
|
|
||||||
|
|
||||||
void* lastmalloced = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* getname -- extracts a secondary key (the last name) from a primary
|
* getname -- extracts a secondary key (the last name) from a primary
|
||||||
* key/data pair
|
* key/data pair
|
||||||
|
@ -57,8 +55,8 @@ int getskey(DB *secondary, const DBT *pkey, const DBT *pdata, DBT *skey)
|
||||||
if (callback_init_data) {
|
if (callback_init_data) {
|
||||||
skey->size = sizeof(entry->skey);
|
skey->size = sizeof(entry->skey);
|
||||||
if (callback_set_malloc) {
|
if (callback_set_malloc) {
|
||||||
skey->data = lastmalloced = malloc(skey->size);
|
skey->data = malloc(skey->size);
|
||||||
memcpy(skey->data, &entry->skey, skey->size);
|
memcpy(skey->data, &entry->skey, skey->size);
|
||||||
}
|
}
|
||||||
else skey->data = &entry->skey;
|
else skey->data = &entry->skey;
|
||||||
}
|
}
|
||||||
|
@ -135,10 +133,10 @@ int main(int argc, const char *argv[]) {
|
||||||
callback_set_malloc = i & (1 << 1);
|
callback_set_malloc = i & (1 << 1);
|
||||||
callback_return_DONOTINDEX = i & (1 << 2);
|
callback_return_DONOTINDEX = i & (1 << 2);
|
||||||
|
|
||||||
lastmalloced = NULL;
|
|
||||||
insert();
|
insert();
|
||||||
check_secondary(callback_return_DONOTINDEX ? DB_NOTFOUND : 0);
|
check_secondary(callback_return_DONOTINDEX ? DB_NOTFOUND : 0);
|
||||||
if (callback_return_DONOTINDEX) free(lastmalloced);
|
// For recent versions of BDB, we don't need to free any malloced object, even if it we returned DB_DONOTINDEX because if we malloced it then we set DB_DBT_APPMALLOC
|
||||||
|
// Older versions of BDB didn't free it. Which versions did?
|
||||||
close_dbs();
|
close_dbs();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue