From: Marcus Boerger Date: Sat, 18 Feb 2006 16:52:30 +0000 (+0000) Subject: - Initiai fix to Bug #36436 DBA problem with Berkeley DB4 X-Git-Tag: RELEASE_1_2~185 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2e1da6ecc26ebc2e27f25be05b2a02d73ee8890;p=php - Initiai fix to Bug #36436 DBA problem with Berkeley DB4 --- diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c index ddfdf341b1..994dd8bd67 100644 --- a/ext/dba/dba_db4.c +++ b/ext/dba/dba_db4.c @@ -139,9 +139,15 @@ DBA_FETCH_FUNC(db4) DB4_GKEY; memset(&gval, 0, sizeof(gval)); + if (info->flags & DBA_PERSISTENT) { + gval.flags |= DB_DBT_MALLOC; + } if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { if (newlen) *newlen = gval.size; new = estrndup(gval.data, gval.size); + if (info->flags & DBA_PERSISTENT) { + free(gval.data); + } } return new; } @@ -210,11 +216,23 @@ DBA_NEXTKEY_FUNC(db4) memset(&gkey, 0, sizeof(gkey)); memset(&gval, 0, sizeof(gval)); + if (info->flags & DBA_PERSISTENT) { + gkey.flags |= DB_DBT_MALLOC; + gval.flags |= DB_DBT_MALLOC; + } if (dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT) == 0) { if (gkey.data) { nkey = estrndup(gkey.data, gkey.size); if (newlen) *newlen = gkey.size; } + if (info->flags & DBA_PERSISTENT) { + if (gkey.data) { + free(gkey.data); + } + if (gval.data) { + free(gval.data); + } + } } return nkey;