aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-03-17 16:17:41 +0200
committerSergey Poznyakoff <gray@gnu.org>2021-03-17 16:28:17 +0200
commite8070a8ba4ecc539483c06221d31da77ede654c2 (patch)
tree31c390a822b2d76283134a738c9b1bf88a4aa015
parentcdef488b4ae700136a2a6227cf25e4393e1fe993 (diff)
downloadgdbm-e8070a8ba4ecc539483c06221d31da77ede654c2.tar.gz
gdbm-e8070a8ba4ecc539483c06221d31da77ede654c2.tar.bz2
Fix memory leak in gdbmtool "next" command.
* src/gdbmtool.c (nextkey_handler): Always free the previous key buffer.
-rw-r--r--src/gdbmdefs.h4
-rw-r--r--src/gdbmtool.c1
2 files changed, 1 insertions, 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);

Return to:

Send suggestions and report system problems to the System administrator.