summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-06-27 19:16:01 -0400
committerTavian Barnes <tavianator@tavianator.com>2019-06-27 19:16:01 -0400
commit257a7060906a25e299e63a367272251a8dc05b83 (patch)
tree5bf4d2b1c3d5224a3f9c7c49f052de3e4f9d386c
parentdad3d53671cf5f4225d8bd9e76786f651371e854 (diff)
downloadbfs-257a7060906a25e299e63a367272251a8dc05b83.tar.xz
color: Fix a crash if strndup() fails
-rw-r--r--color.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/color.c b/color.c
index aefc3ff..9806b52 100644
--- a/color.c
+++ b/color.c
@@ -432,14 +432,14 @@ struct colors *parse_colors(const char *ls_colors) {
break;
}
- char *key = strndup(chunk, equals - chunk);
- if (!key) {
+ char *value = unescape(equals + 1, ':', &next);
+ if (!value) {
continue;
}
- char *value = unescape(equals + 1, ':', &next);
- if (!value) {
- free(key);
+ char *key = strndup(chunk, equals - chunk);
+ if (!key) {
+ dstrfree(value);
continue;
}