aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-28 14:54:20 -0700
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2016-10-28 14:54:20 -0700
commitb27033bc35dcef9d4a65788bd613473add3e3887 (patch)
treeb31e3cae33281c45288f4c4edd99618175de6f64 /util
parent695e45a4de50a9164766a7d73656b1afc9244a56 (diff)
Fix memory leak in fusermount.
Diffstat (limited to 'util')
-rw-r--r--util/fusermount.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/util/fusermount.c b/util/fusermount.c
index 41061bb..03da451 100644
--- a/util/fusermount.c
+++ b/util/fusermount.c
@@ -1206,7 +1206,7 @@ int main(int argc, char *argv[])
res = chdir("/");
if (res == -1) {
fprintf(stderr, "%s: failed to chdir to '/'\n", progname);
- exit(1);
+ goto err_out;
}
}
restore_privs();
@@ -1221,21 +1221,23 @@ int main(int argc, char *argv[])
if (commfd == NULL) {
fprintf(stderr, "%s: old style mounting not supported\n",
progname);
- exit(1);
+ goto err_out;
}
fd = mount_fuse(mnt, opts);
if (fd == -1)
- exit(1);
+ goto err_out;
cfd = atoi(commfd);
res = send_fd(cfd, fd);
if (res == -1)
- exit(1);
+ goto err_out;
close(fd);
- if (!auto_unmount)
+ if (!auto_unmount) {
+ free(mnt);
return 0;
+ }
/* Become a daemon and wait for the parent to exit or die.
ie For the control socket to get closed.
@@ -1245,7 +1247,7 @@ int main(int argc, char *argv[])
res = chdir("/");
if (res == -1) {
fprintf(stderr, "%s: failed to chdir to '/'\n", progname);
- exit(1);
+ goto err_out;
}
sigfillset(&sigset);
@@ -1278,6 +1280,10 @@ do_unmount:
progname, mnt, strerror(errno));
}
if (res == -1)
- exit(1);
+ goto err_out;
return 0;
+
+err_out:
+ free(mnt);
+ exit(1);
}