aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-03-22 16:44:47 +0200
committerSergey Poznyakoff <gray@gnu.org>2021-03-22 16:54:00 +0200
commita84e72a583c3ea6d261447ec1560bf0d3cb32356 (patch)
treea771ed88acb675b7e82e01cf90eb9c3800a95134
parent8f9af0917131436651449306dbcedcff5dcec2c2 (diff)
downloadgdbm-a84e72a583c3ea6d261447ec1560bf0d3cb32356.tar.gz
gdbm-a84e72a583c3ea6d261447ec1560bf0d3cb32356.tar.bz2
Fix minor memory leaks in gdbmtool
* src/datconv.c (dsegm_list_free): Free name if necessary. * src/gram.y (defid): Free $1 when no longer needed.
-rw-r--r--src/datconv.c2
-rw-r--r--src/gram.y11
2 files changed, 11 insertions, 2 deletions
diff --git a/src/datconv.c b/src/datconv.c
index 7e9e532..ead1e57 100644
--- a/src/datconv.c
+++ b/src/datconv.c
@@ -206,6 +206,8 @@ dsegm_list_free (struct dsegm *dp)
while (dp)
{
struct dsegm *next = dp->next;
+ if (dp->type == FDEF_FLD)
+ free (dp->v.field.name);
free (dp);
dp = next;
}
diff --git a/src/gram.y b/src/gram.y
index 7ad314e..60769e9 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -219,13 +219,20 @@ optcomma : /* empty */
defid : T_IDENT
{
if (strcmp ($1, "key") == 0)
- $$ = DS_KEY;
+ {
+ $$ = DS_KEY;
+ free ($1);
+ }
else if (strcmp ($1, "content") == 0)
- $$ = DS_CONTENT;
+ {
+ $$ = DS_CONTENT;
+ free ($1);
+ }
else
{
terror (_("expected \"key\" or \"content\", "
"but found \"%s\""), $1);
+ free ($1);
YYERROR;
}
}

Return to:

Send suggestions and report system problems to the System administrator.