[systemd-devel] [PATCH] dbus1-generator: fix resource leak on file pointer f
Colin King
colin.king at canonical.com
Thu Jun 12 09:44:42 PDT 2014
From: Colin Ian King <colin.king at canonical.com>
File pointer f is not closed on the multiple error exit paths
or on the end of create_dbus_files() causing multiple points
of a resource leak. Close f on the appropriate paths.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/dbus1-generator/dbus1-generator.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index 95962c7..fe44996 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -92,6 +92,7 @@ static int create_dbus_files(
run = getenv("XDG_RUNTIME_DIR");
if (!run) {
log_error("XDG_RUNTIME_DIR not set.");
+ fclose(f);
return -EINVAL;
}
@@ -103,8 +104,10 @@ static int create_dbus_files(
fflush(f);
if (ferror(f)) {
log_error("Failed to write %s: %m", a);
+ fclose(f);
return -errno;
}
+ fclose(f);
service = s;
}
@@ -137,8 +140,10 @@ static int create_dbus_files(
fflush(f);
if (ferror(f)) {
log_error("Failed to write %s: %m", b);
+ fclose(f);
return -errno;
}
+ fclose(f);
lnk = strjoin(arg_dest_late, "/" SPECIAL_BUSNAMES_TARGET ".wants/", name, ".busname", NULL);
if (!lnk)
--
2.0.0
More information about the systemd-devel
mailing list