diff options
author | Phil Jones <philj56@gmail.com> | 2022-12-11 16:57:23 +0000 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-12-11 16:57:23 +0000 |
commit | 4ac4408ee7d9af91b9f9e3c7734aa2f673ef5cdc (patch) | |
tree | 3edbdf3ef587b9c620cacb666b05b454fd810829 /src/compgen.c | |
parent | 0efb3c61a9575eede8984f362dfa6cd0b7562f4a (diff) |
Fix a couple of cache-generation memory leaks.
Diffstat (limited to 'src/compgen.c')
-rw-r--r-- | src/compgen.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/compgen.c b/src/compgen.c index 4e91fda..af8050d 100644 --- a/src/compgen.c +++ b/src/compgen.c @@ -125,11 +125,10 @@ char *compgen_cached() if (stat(cache_path, &sb) == -1) { if (errno == ENOENT) { char *commands = compgen(); - if (!mkdirp(cache_path)) { - free(cache_path); - return commands; + if (mkdirp(cache_path)) { + write_cache(commands, cache_path); } - write_cache(commands, cache_path); + free(cache_path); return commands; } free(cache_path); @@ -224,6 +223,8 @@ char *compgen() } buf[bytes_written] = '\0'; + string_vec_destroy(&programs); + return buf; } |