aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Rostislav Skudnov <rostislav@tuxera.com>2018-07-21 21:14:19 +0000
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2018-07-23 11:02:57 +0100
commita2a09e7cca6ddda42c5523654df057fa1578500e (patch)
tree47e809010b047261e4bafad6ecd0339c75bb6f4d
parentc7ae066cb455ba7beafe8a8b9091a05a36c9bd55 (diff)
example/{hello,null}: Fix memory leaks
-rw-r--r--example/hello.c5
-rw-r--r--example/null.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/example/hello.c b/example/hello.c
index 95aed48..57d3ecd 100644
--- a/example/hello.c
+++ b/example/hello.c
@@ -149,6 +149,7 @@ static void show_help(const char *progname)
int main(int argc, char *argv[])
{
+ int ret;
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
/* Set defaults -- we have to use strdup so that
@@ -172,5 +173,7 @@ int main(int argc, char *argv[])
args.argv[0] = (char*) "";
}
- return fuse_main(args.argc, args.argv, &hello_oper, NULL);
+ ret = fuse_main(args.argc, args.argv, &hello_oper, NULL);
+ fuse_opt_free_args(&args);
+ return ret;
}
diff --git a/example/null.c b/example/null.c
index c90e86d..ed68c0b 100644
--- a/example/null.c
+++ b/example/null.c
@@ -27,6 +27,7 @@
#include <fuse.h>
#include <fuse_lowlevel.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
@@ -119,6 +120,7 @@ int main(int argc, char *argv[])
if (fuse_parse_cmdline(&args, &opts) != 0)
return 1;
+ fuse_opt_free_args(&args);
if (!opts.mountpoint) {
fprintf(stderr, "missing mountpoint parameter\n");
@@ -128,8 +130,10 @@ int main(int argc, char *argv[])
if (stat(opts.mountpoint, &stbuf) == -1) {
fprintf(stderr ,"failed to access mountpoint %s: %s\n",
opts.mountpoint, strerror(errno));
+ free(opts.mountpoint);
return 1;
}
+ free(opts.mountpoint);
if (!S_ISREG(stbuf.st_mode)) {
fprintf(stderr, "mountpoint is not a regular file\n");
return 1;