mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-08-02 04:22:45 +03:00
dbus1-generator: properly free the FILE*
Also, rework the code to make use of fflush_and_check(). Issue discovered by Simon Danner.
This commit is contained in:
@ -40,6 +40,7 @@ static int create_dbus_files(
|
||||
|
||||
_cleanup_free_ char *b = NULL, *s = NULL, *lnk = NULL;
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
int r;
|
||||
|
||||
assert(path);
|
||||
assert(name);
|
||||
@ -100,12 +101,15 @@ static int create_dbus_files(
|
||||
}
|
||||
}
|
||||
|
||||
fflush(f);
|
||||
if (ferror(f)) {
|
||||
log_error("Failed to write %s: %m", a);
|
||||
return -errno;
|
||||
r = fflush_and_check(f);
|
||||
if (r < 0) {
|
||||
log_error("Failed to write %s: %s", a, strerror(-r));
|
||||
return r;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
|
||||
service = s;
|
||||
}
|
||||
|
||||
@ -134,10 +138,10 @@ static int create_dbus_files(
|
||||
name,
|
||||
service);
|
||||
|
||||
fflush(f);
|
||||
if (ferror(f)) {
|
||||
log_error("Failed to write %s: %m", b);
|
||||
return -errno;
|
||||
r = fflush_and_check(f);
|
||||
if (r < 0) {
|
||||
log_error("Failed to write %s: %s", b, strerror(-r));
|
||||
return r;
|
||||
}
|
||||
|
||||
lnk = strjoin(arg_dest_late, "/" SPECIAL_BUSNAMES_TARGET ".wants/", name, ".busname", NULL);
|
||||
|
Reference in New Issue
Block a user