mirror of
https://github.com/systemd/systemd.git
synced 2025-01-21 22:04:01 +03:00
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.
This commit is contained in:
parent
25cb94d431
commit
7645c77b9b
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user