summaryrefslogtreecommitdiffstats
path: root/lib/colors.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/colors.c')
-rw-r--r--lib/colors.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/colors.c b/lib/colors.c
index fb7d4b225..ab62c5652 100644
--- a/lib/colors.c
+++ b/lib/colors.c
@@ -438,8 +438,9 @@ static int cn_sequence(const char *str, char **seq)
/*
- * Adds one color sequence to array with color scheme,
- * @seq and @name have to be allocated strings
+ * Adds one color sequence to array with color scheme.
+ * When returning success (0) this function takes ownership of
+ * @seq and @name, which have to be allocated strings.
*/
static int colors_add_scheme(struct ul_color_ctl *cc,
char *name,
@@ -455,7 +456,6 @@ static int colors_add_scheme(struct ul_color_ctl *cc,
DBG(SCHEME, ul_debug("add '%s'", name));
rc = cn_sequence(seq0, &seq);
- free(seq0);
if (rc)
return rc;
@@ -485,6 +485,8 @@ static int colors_add_scheme(struct ul_color_ctl *cc,
cc->schemes_sz = cc->nschemes + 10;
}
+ free(seq0);
+
/* add a new item */
cs = &cc->schemes[cc->nschemes++];
cs->name = name;