summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVáclav Pavlín <vpavlin@redhat.com>2013-03-27 15:16:37 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-27 12:01:44 -0400
commitf36a783ca7b8200d4e865a49342e44929c0f4c06 (patch)
treee43cf0bd19321063b74f78d0e21b28b30b67f293
parentebf4fb3d368732d9f41cb40e3084182c04e731b2 (diff)
shared: free dt (temporary dir name) on fail
[zj: modified to not to try to rmdir() dir we haven't created.]
-rw-r--r--src/shared/util.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 0444cf4456..8fa01fa8a4 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5708,7 +5708,7 @@ int create_tmp_dir(char template[], char** dir_name) {
dt = strjoin(d, "/tmp", NULL);
if (!dt) {
r = log_oom();
- goto fail2;
+ goto fail3;
}
umask(0000);
@@ -5716,7 +5716,7 @@ int create_tmp_dir(char template[], char** dir_name) {
if (r) {
log_error("Can't create directory %s: %m", dt);
r = -errno;
- goto fail1;
+ goto fail2;
}
log_debug("Created temporary directory %s", dt);
@@ -5734,6 +5734,8 @@ int create_tmp_dir(char template[], char** dir_name) {
fail1:
rmdir(dt);
fail2:
+ free(dt);
+fail3:
rmdir(template);
return r;
}