summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mcscolor.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mcscolor.c b/src/mcscolor.c
index ebe5be0..b3df206 100644
--- a/src/mcscolor.c
+++ b/src/mcscolor.c
@@ -97,12 +97,17 @@ static int check_dominance(const char *pattern, const char *raw) {
struct av_decision avd;
int rc = -1;
context_t my_tmp;
- const char *raw_range;
+ char *raw_range;
con = context_new(raw);
if (!con)
return -1;
- raw_range = context_range_get(con);
+ raw_range = strdup(context_range_get(con));
+ if (!raw_range) {
+ context_free(con);
+ return -1;
+ }
+ *strchrnul(raw_range, '-') = '\0';
my_tmp = context_new(my_context);
if (!my_tmp) {
@@ -129,6 +134,7 @@ static int check_dominance(const char *pattern, const char *raw) {
rc = (bit & avd.allowed) != bit;
out:
+ free(raw_range);
free(ctx);
context_free(my_tmp);
context_free(con);