summaryrefslogtreecommitdiffstats
path: root/color.c
diff options
context:
space:
mode:
Diffstat (limited to 'color.c')
-rw-r--r--color.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/color.c b/color.c
index f04bdf5..509e646 100644
--- a/color.c
+++ b/color.c
@@ -120,11 +120,14 @@ static char **get_color(const struct colors *colors, const char *name) {
}
/** Set the value of a color. */
-static void set_color(struct colors *colors, const char *name, char *value) {
+static int set_color(struct colors *colors, const char *name, char *value) {
char **color = get_color(colors, name);
if (color) {
dstrfree(*color);
*color = value;
+ return 0;
+ } else {
+ return -1;
}
}
@@ -462,7 +465,9 @@ struct colors *parse_colors(const char *ls_colors) {
value = NULL;
}
- set_color(colors, key, value);
+ if (set_color(colors, key, value) != 0) {
+ dstrfree(value);
+ }
free(key);
}
}