diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-03-25 18:19:52 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-03-25 18:20:03 +0100 |
commit | 80c39ad27f5e99b1f18bdacd2b27a05ddee6cca1 (patch) | |
tree | ac3d7a028a5616d260aef85245887131d71edc62 /src/fstab-generator | |
parent | df3e57f542cf680cd891dfbd85615885b54770dc (diff) |
fstab-generator: fix minor memory leak on error path
Diffstat (limited to 'src/fstab-generator')
-rw-r--r-- | src/fstab-generator/fstab-generator.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index a0a87a15fc..7f065eb353 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -468,8 +468,8 @@ finish: } static int parse_new_root_from_proc_cmdline(void) { - char *w, *state; _cleanup_free_ char *what = NULL, *type = NULL, *opts = NULL, *line = NULL; + char *w, *state; int r; size_t l; @@ -487,7 +487,7 @@ static int parse_new_root_from_proc_cmdline(void) { /* root= and roofstype= may occur more than once, the last instance should take precedence. * In the case of multiple rootflags= the arguments should be concatenated */ FOREACH_WORD_QUOTED(w, l, line, state) { - char *word, *tmp_word; + _cleanup_free_ char *word; word = strndup(w, l); if (!word) @@ -506,22 +506,25 @@ static int parse_new_root_from_proc_cmdline(void) { return log_oom(); } else if (startswith(word, "rootflags=")) { - tmp_word = opts; - opts = strjoin(opts, ",", word + 10, NULL); - free(tmp_word); - if (!opts) + char *o; + + o = strjoin(opts, ",", word + 10, NULL); + if (!o) return log_oom(); + free(opts); + opts = o; + } else if (streq(word, "ro") || streq(word, "rw")) { - tmp_word = opts; - opts = strjoin(opts, ",", word, NULL); - free(tmp_word); - if (!opts) + char *o; + + o = strjoin(opts, ",", word, NULL); + if (!o) return log_oom(); + free(opts); + opts = o; } - - free(word); } if (!what) { |