diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2019-06-27 19:16:01 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-06-27 19:16:01 -0400 |
commit | 257a7060906a25e299e63a367272251a8dc05b83 (patch) | |
tree | 5bf4d2b1c3d5224a3f9c7c49f052de3e4f9d386c | |
parent | dad3d53671cf5f4225d8bd9e76786f651371e854 (diff) | |
download | bfs-257a7060906a25e299e63a367272251a8dc05b83.tar.xz |
color: Fix a crash if strndup() fails
-rw-r--r-- | color.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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; } |