From: Francois Fleuret Date: Tue, 8 Oct 2019 05:38:59 +0000 (+0200) Subject: Cleaned up the regexp de-allocation + syntax check for --delete-regexp. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=55f56e90089881b60c29d86168c7057e2191209f;p=selector.git Cleaned up the regexp de-allocation + syntax check for --delete-regexp. --- diff --git a/selector.c b/selector.c index f573d79..4f4c0bc 100644 --- a/selector.c +++ b/selector.c @@ -1126,7 +1126,11 @@ int main(int argc, char **argv) { case OPT_DELETE_REGEXP: free(global_prefix_regexp); global_prefix_regexp = safe_malloc(sizeof(*global_prefix_regexp)); - regcomp(global_prefix_regexp, optarg, 0); + + if(regcomp(global_prefix_regexp, optarg, 0)) { + fprintf(stderr, "selector: Regexp syntax error `%s'.\n", optarg); + exit(EXIT_FAILURE); + } break; case 'r': @@ -1463,7 +1467,11 @@ int main(int argc, char **argv) { free(labels); free(lines); free(global_title); - free(global_prefix_regexp); + + if(global_prefix_regexp) { + regfree(global_prefix_regexp); + free(global_prefix_regexp); + } exit(EXIT_SUCCESS); }