summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2018-05-30 07:21:32 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-05-30 07:21:32 (GMT)
commited14564822983b6b7cfa7b3c7d8104b15a019255 (patch) (side-by-side diff)
treeec5db19f319930830904381de7be93be2e47f565
parent5e2333e8119113c729874982eca32941162fe811 (diff)
downloadgdbm-ed14564822983b6b7cfa7b3c7d8104b15a019255.tar.gz
gdbm-ed14564822983b6b7cfa7b3c7d8104b15a019255.tar.bz2
Fix memory leak in _gdbm_get_bucket
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/bucket.c2
-rw-r--r--src/gdbmopen.c6
-rw-r--r--src/proto.h2
3 files changed, 5 insertions, 5 deletions
diff --git a/src/bucket.c b/src/bucket.c
index 7d65e32..c75db42 100644
--- a/src/bucket.c
+++ b/src/bucket.c
@@ -128,7 +128,7 @@ _gdbm_get_bucket (GDBM_FILE dbf, int dir_index)
if (_gdbm_write_bucket (dbf, &dbf->bucket_cache[lru]))
return -1;
}
- _gdbm_init_cache_entry (dbf, lru);
+ _gdbm_cache_entry_invalidate (dbf, lru);
/* Read the bucket. */
rc = GDBM_DEBUG_OVERRIDE ("_gdbm_get_bucket:read-failure",
diff --git a/src/gdbmopen.c b/src/gdbmopen.c
index 5d8dc50..9c10d3d 100644
--- a/src/gdbmopen.c
+++ b/src/gdbmopen.c
@@ -653,7 +653,8 @@ _gdbm_init_cache (GDBM_FILE dbf, size_t size)
GDBM_SET_ERRNO (dbf, GDBM_MALLOC_ERROR, TRUE);
return -1;
}
- _gdbm_init_cache_entry (dbf, index);
+ dbf->bucket_cache[index].ca_data.dptr = NULL;
+ _gdbm_cache_entry_invalidate (dbf, index);
}
dbf->bucket = dbf->bucket_cache[0].ca_bucket;
dbf->cache_entry = &dbf->bucket_cache[0];
@@ -662,11 +663,10 @@ _gdbm_init_cache (GDBM_FILE dbf, size_t size)
}
void
-_gdbm_init_cache_entry (GDBM_FILE dbf, int index)
+_gdbm_cache_entry_invalidate (GDBM_FILE dbf, int index)
{
dbf->bucket_cache[index].ca_adr = 0;
dbf->bucket_cache[index].ca_changed = FALSE;
dbf->bucket_cache[index].ca_data.hash_val = -1;
dbf->bucket_cache[index].ca_data.elem_loc = -1;
- dbf->bucket_cache[index].ca_data.dptr = NULL;
}
diff --git a/src/proto.h b/src/proto.h
index c8c9e53..9592f52 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -48,7 +48,7 @@ void _gdbm_fatal (GDBM_FILE, const char *);
/* From gdbmopen.c */
int _gdbm_init_cache (GDBM_FILE, size_t);
-void _gdbm_init_cache_entry (GDBM_FILE, int);
+void _gdbm_cache_entry_invalidate (GDBM_FILE, int);
int gdbm_avail_block_validate (GDBM_FILE dbf, avail_block *avblk);
int gdbm_bucket_avail_table_validate (GDBM_FILE dbf, hash_bucket *bucket);

Return to:

Send suggestions and report system problems to the System administrator.