diff options
author | Anchit Narang <anchit.n@samsung.com> | 2015-07-29 14:06:55 +0530 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-07-29 20:46:28 +0300 |
commit | 95f254e69972acaf4be4688aa8affcfa9b2cee19 (patch) | |
tree | 4cfcf7e62bf0b28a5aaafd6c25315f65bd7ec9d7 /tools/l2test.c | |
parent | f17d3a2c3b0d4a8869ff297f53d55d1cdd524421 (diff) | |
download | bluez-95f254e69972acaf4be4688aa8affcfa9b2cee19.tar.gz |
tools/l2test:Fixed memory leak
Removed dynamic allocation of filename by strdup.
Instead filename is directly pointing to the argv element.
Closed the file before returning from do_send function.
Diffstat (limited to 'tools/l2test.c')
-rw-r--r-- | tools/l2test.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/l2test.c b/tools/l2test.c index 1d458c4cc..386823f8a 100644 --- a/tools/l2test.c +++ b/tools/l2test.c @@ -114,7 +114,7 @@ static unsigned long disc_delay = 0; /* Initial sequence value when sending frames */ static int seq_start = 0; -static char *filename = NULL; +static const char *filename = NULL; static int rfcmode = 0; static int master = 0; @@ -974,6 +974,8 @@ static void do_send(int sk) sent += len; size -= len; } + + close(fd); return; } else { for (i = 6; i < data_size; i++) @@ -1449,7 +1451,7 @@ int main(int argc, char *argv[]) break; case 'B': - filename = strdup(optarg); + filename = optarg; break; case 'N': |