summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compgen.c9
-rw-r--r--src/desktop_vec.c10
2 files changed, 11 insertions, 8 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;
}
diff --git a/src/desktop_vec.c b/src/desktop_vec.c
index de7fcd7..c9a0b86 100644
--- a/src/desktop_vec.c
+++ b/src/desktop_vec.c
@@ -81,7 +81,8 @@ void desktop_vec_add_file(struct desktop_vec *vec, const char *id, const char *p
*/
char *keywords = g_key_file_get_locale_string(file, group, "Keywords", NULL, NULL);
if (keywords == NULL) {
- keywords = "";
+ keywords = xmalloc(1);
+ *keywords = '\0';
}
gsize length;
@@ -91,7 +92,7 @@ void desktop_vec_add_file(struct desktop_vec *vec, const char *id, const char *p
g_strfreev(list);
list = NULL;
if (!match) {
- goto cleanup_name;
+ goto cleanup_all;
}
}
@@ -101,13 +102,14 @@ void desktop_vec_add_file(struct desktop_vec *vec, const char *id, const char *p
g_strfreev(list);
list = NULL;
if (match) {
- goto cleanup_name;
+ goto cleanup_all;
}
}
desktop_vec_add(vec, id, name, path, keywords);
-cleanup_name:
+cleanup_all:
+ free(keywords);
free(name);
cleanup_file:
g_key_file_unref(file);