From e8070a8ba4ecc539483c06221d31da77ede654c2 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Wed, 17 Mar 2021 16:17:41 +0200 Subject: Fix memory leak in gdbmtool "next" command. * src/gdbmtool.c (nextkey_handler): Always free the previous key buffer. --- src/gdbmdefs.h | 4 ---- src/gdbmtool.c | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gdbmdefs.h b/src/gdbmdefs.h index dfb6d60..3fec82c 100644 --- a/src/gdbmdefs.h +++ b/src/gdbmdefs.h @@ -66,10 +66,6 @@ typedef struct avail_elem av_table[1]; /* The table. Make it look like an array. */ } avail_block; -/* Return true if both AV and the size of AV->av_table are valid. - See comment to this function in gdbmopen.c */ -extern int gdbm_avail_table_valid_p (GDBM_FILE dbf, avail_elem *av, int count); - /* The dbm file header keeps track of the current location of the hash directory and the free space in the file. */ diff --git a/src/gdbmtool.c b/src/gdbmtool.c index 7924a40..7fbecc0 100644 --- a/src/gdbmtool.c +++ b/src/gdbmtool.c @@ -481,6 +481,7 @@ nextkey_handler (struct handler_param *param) return_data = gdbm_nextkey (gdbm_file, key_data); if (return_data.dptr != NULL) { + free (key_data.dptr); key_data = return_data; datum_format (param->fp, &key_data, dsdef[DS_KEY]); fputc ('\n', param->fp); -- cgit v1.2.1