Fix memory leak and print a warning on invalid regex

This will minimize the already low memory usage of sent.
This commit is contained in:
FRIGN 2016-08-11 21:30:34 +02:00 committed by Markus Teich
parent e8914d5d4b
commit 072a318adb

6
sent.c
View File

@ -185,12 +185,16 @@ ffload(Slide *s)
for (i = 0; i < LEN(filters); i++) {
if (regcomp(&regex, filters[i].regex,
REG_NOSUB | REG_EXTENDED | REG_ICASE))
REG_NOSUB | REG_EXTENDED | REG_ICASE)) {
fprintf(stderr, "sent: Invalid regex '%s'\n", filters[i].regex);
continue;
}
if (!regexec(&regex, filename, 0, NULL, 0)) {
bin = filters[i].bin;
regfree(&regex);
break;
}
regfree(&regex);
}
if (!bin)
die("sent: Unable to find matching filter for file %s", filename);