commit 59adcd33c1e354bfddfdd4ae86c142a348957a39
parent 6ad7be2b64423374a60a94398762d4792899b7a1
Author: Svyatoslav Mishyn <juef@openmailbox.org>
Date: Tue, 9 Aug 2016 16:08:55 +0300
add REG_NOSUB flag and fix a memory leak
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/soap.c b/soap.c
@@ -39,11 +39,12 @@ main(int argc, char *argv[]){
/* check regex and launch action if it matches argv[1] */
for (i=0; i < sizeof(pairs)/sizeof(*pairs); ++i) {
- if (regcomp(®ex, pairs[i].regex, REG_EXTENDED))
+ if (regcomp(®ex, pairs[i].regex, REG_EXTENDED | REG_NOSUB))
fprintf(stderr, "invalid regex: %s\n", pairs[i].regex);
if (!regexec(®ex, argv[1], 0, NULL, 0)) {
snprintf(cmd, sizeof cmd, pairs[i].action, sharg);
system(cmd);
+ regfree(®ex);
return EXIT_SUCCESS;
}
regfree(®ex);