diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-01-31 17:36:08 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-01-31 17:41:46 +0100 |
commit | 7645c77b9bba2944f75db0276b93ef83d2393661 (patch) | |
tree | cad6ef5c25ec167249f17c56a979aed6e81a1234 /src/journal | |
parent | core/timer: use (void) (diff) | |
download | systemd-7645c77b9bba2944f75db0276b93ef83d2393661.tar.xz systemd-7645c77b9bba2944f75db0276b93ef83d2393661.zip |
journal-file: check asprintf return value in the usual fashion
This is unlikely to fail, but we cannot rely on asprintf return value
on failure, so let's just be correct here.
CID #1368236.
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/journal-file.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index d3e0214731..bb1443725f 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -3087,13 +3087,18 @@ int journal_file_open( } } - if (fname) + if (fname) { f->path = strdup(fname); - else /* If we don't know the path, fill in something explanatory and vaguely useful */ - asprintf(&f->path, "/proc/self/%i", fd); - if (!f->path) { - r = -ENOMEM; - goto fail; + if (!f->path) { + r = -ENOMEM; + goto fail; + } + } else { + /* If we don't know the path, fill in something explanatory and vaguely useful */ + if (asprintf(&f->path, "/proc/self/%i", fd) < 0) { + r = -ENOMEM; + goto fail; + } } f->chain_cache = ordered_hashmap_new(&uint64_hash_ops); |