diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-17 21:52:57 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-03-18 18:53:59 -0400 |
commit | 6180fc611b415e2a26c64658d2ce700f457f4a67 (patch) | |
tree | 4881be5661afe14e381efa5b72b8870f060382ee /src/journal/sd-journal.c | |
parent | 85b2850ba94a2a0c15239893c446b3db39b36638 (diff) |
journal: use sd_journal_close on error in sd_journal_new
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r-- | src/journal/sd-journal.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index fa04bfdfc8..2c5ee3f8f6 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -1568,37 +1568,21 @@ static sd_journal *journal_new(int flags, const char *path) { if (path) { j->path = strdup(path); - if (!j->path) { - free(j); - return NULL; - } + if (!j->path) + goto fail; } j->files = hashmap_new(string_hash_func, string_compare_func); - if (!j->files) { - free(j->path); - free(j); - return NULL; - } - j->directories_by_path = hashmap_new(string_hash_func, string_compare_func); - if (!j->directories_by_path) { - hashmap_free(j->files); - free(j->path); - free(j); - return NULL; - } - j->mmap = mmap_cache_new(); - if (!j->mmap) { - hashmap_free(j->files); - hashmap_free(j->directories_by_path); - free(j->path); - free(j); - return NULL; - } + if (!j->files || !j->directories_by_path || !j->mmap) + goto fail; return j; + +fail: + sd_journal_close(j); + return NULL; } _public_ int sd_journal_open(sd_journal **ret, int flags) { |