1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

journal-remote: fix memory leak on initialization error

Follow-up for f12b399dd6 from
https://github.com/systemd/systemd/pull/25076

CID#1501550
This commit is contained in:
Luca Boccassi 2022-12-18 10:58:37 +00:00
parent a4f82d2cd7
commit 4bf277caa5

View File

@ -22,7 +22,7 @@ static int do_rotate(ManagedJournalFile **f, MMapCache *m, JournalFileFlags file
}
Writer* writer_new(RemoteServer *server) {
Writer *w;
_cleanup_(writer_unrefp) Writer *w = NULL;
int r;
w = new0(Writer, 1);
@ -33,7 +33,7 @@ Writer* writer_new(RemoteServer *server) {
w->mmap = mmap_cache_new();
if (!w->mmap)
return mfree(w);
return NULL;
w->n_ref = 1;
w->server = server;
@ -50,7 +50,7 @@ Writer* writer_new(RemoteServer *server) {
}
}
return w;
return TAKE_PTR(w);
}
static Writer* writer_free(Writer *w) {