From: Lennart Poettering Date: Thu, 23 Jul 2015 21:36:34 +0000 (+0200) Subject: fileio: get_status_field() don't clobber arg on OOM X-Git-Tag: v223~50^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=901108257e3b1da07033f4e6e053b5be42b1c8b0;p=platform%2Fupstream%2Fsystemd.git 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. --- diff --git a/src/basic/fileio.c b/src/basic/fileio.c index d592bf5..2216853 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; }