summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2006-08-27 11:53:19 +0000
committerMarcel Holtmann <marcel@holtmann.org>2006-08-27 11:53:19 +0000
commit11585f79a9aebf19bfe837b000d93cff2f08db14 (patch)
tree05b3b23dca5633999096d675002aed53543b9904 /hcid
parent2f1fece0402ce32292bc17dae43e3becbd19683f (diff)
Fix memory leaks in the config file parser
Diffstat (limited to 'hcid')
-rw-r--r--hcid/main.c2
-rw-r--r--hcid/parser.y12
2 files changed, 9 insertions, 5 deletions
diff --git a/hcid/main.c b/hcid/main.c
index dd3367b7..567dfab3 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -80,7 +80,7 @@ struct device_opts *alloc_device_opts(char *ref)
exit(1);
}
- device->ref = ref;
+ device->ref = strdup(ref);
device->next = device_list;
device_list = device;
diff --git a/hcid/parser.y b/hcid/parser.y
index aae915e9..cf947fbf 100644
--- a/hcid/parser.y
+++ b/hcid/parser.y
@@ -50,6 +50,8 @@ int yyparse(void);
int yylex(void);
int yyerror(char *s);
+void yylex_destroy(void);
+
%}
%union {
@@ -221,23 +223,23 @@ device_opt:
dev_name:
WORD {
- $$ = strdup($1);
+ $$ = $1;
}
| STRING {
- $$ = strdup($1);
+ $$ = $1;
}
;
hci:
HCI {
- $$ = strdup($1);
+ $$ = $1;
}
;
bdaddr:
BDADDR {
- $$ = strdup($1);
+ $$ = $1;
}
;
@@ -329,5 +331,7 @@ int read_config(char *file)
fclose(yyin);
+ yylex_destroy();
+
return 0;
}