summaryrefslogtreecommitdiff
path: root/src/basic/fileio.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-07-23 23:36:34 +0200
committerLennart Poettering <lennart@poettering.net>2015-07-23 23:36:36 +0200
commit901108257e3b1da07033f4e6e053b5be42b1c8b0 (patch)
treebd71cdb965e9c1b6c77c5ea8c5fc1a8c46f877c8 /src/basic/fileio.c
parentc5f44880ca35bc0246ddf90cbf2af45b10e4a4d5 (diff)
fileio: get_status_field() don't clobber arg on OOM
According to our coding style guidelines we shouldn't clobber pass-by-ref arguments on failure, hence don't do so here either.
Diffstat (limited to 'src/basic/fileio.c')
-rw-r--r--src/basic/fileio.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index d592bf5ac9..2216853777 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -786,7 +786,7 @@ int executable_is_script(const char *path, char **interpreter) {
*/
int get_status_field(const char *filename, const char *pattern, char **field) {
_cleanup_free_ char *status = NULL;
- char *t;
+ char *t, *f;
size_t len;
int r;
@@ -820,9 +820,10 @@ int get_status_field(const char *filename, const char *pattern, char **field) {
len = strcspn(t, WHITESPACE);
- *field = strndup(t, len);
- if (!*field)
+ f = strndup(t, len);
+ if (!f)
return -ENOMEM;
+ *field = f;
return 0;
}