noice

small file browser
git clone git://git.2f30.org/noice.git
Log | Files | Refs | README | LICENSE

commit fef811921b50a2e4a3501e4cef47286c855b4727
parent 2f11fc5427127bcfdf84dd4e1c71c5c91157088c
Author: Lazaros Koromilas <lostd@2f30.org>
Date:   Sun, 25 Feb 2018 12:29:18 +0200

Plug regex memory leaks

Diffstat:
noice.c | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/noice.c b/noice.c @@ -213,8 +213,10 @@ openwith(char *file) continue; if (regexec(&regex, file, 0, NULL, 0) == 0) { bin = assocs[i].bin; + regfree(&regex); break; } + regfree(&regex); } DPRINTF_S(bin); return bin; @@ -239,6 +241,12 @@ setfilter(regex_t *regex, char *filter) } void +freefilter(regex_t *regex) +{ + regfree(regex); +} + +void initfilter(int dot, char **ifilter) { *ifilter = dot ? "." : "^[^.]"; @@ -520,6 +528,7 @@ populate(char *path, char *oldpath, char *fltr) dents = NULL; ndents = dentfill(path, &dents, visible, &re); + freefilter(&re); qsort(dents, ndents, sizeof(*dents), entrycmp); @@ -677,6 +686,7 @@ nochange: r = setfilter(&re, tmp); if (r != 0) goto nochange; + freefilter(&re); strlcpy(fltr, tmp, sizeof(fltr)); DPRINTF_S(fltr); /* Save current */