From 072a318adbdf091a58587c740d081d0ccfff271c Mon Sep 17 00:00:00 2001 From: FRIGN Date: Thu, 11 Aug 2016 21:30:34 +0200 Subject: [PATCH] Fix memory leak and print a warning on invalid regex This will minimize the already low memory usage of sent. --- sent.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sent.c b/sent.c index a4d0cd2..1e1353c 100644 --- a/sent.c +++ b/sent.c @@ -185,12 +185,16 @@ ffload(Slide *s) for (i = 0; i < LEN(filters); i++) { if (regcomp(®ex, 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(®ex, filename, 0, NULL, 0)) { bin = filters[i].bin; + regfree(®ex); break; } + regfree(®ex); } if (!bin) die("sent: Unable to find matching filter for file %s", filename);