summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <none@none>2012-09-01 02:38:51 +0200
committerportix <none@none>2012-09-01 02:38:51 +0200
commitce87b3a3de2142a065bf10b7f510a201f8826c82 (patch)
tree16806f7f423ac04dde4c5fc78b9c3dfcdbd0ccee
parent1814d379f3ed4cc8675434b0e51832aa6bb4c43e (diff)
downloaddwb-ce87b3a3de2142a065bf10b7f510a201f8826c82.zip
Free memory obtained by get_list
-rw-r--r--tools/dwbem.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/dwbem.c b/tools/dwbem.c
index 65920086..dac937bb 100644
--- a/tools/dwbem.c
+++ b/tools/dwbem.c
@@ -678,16 +678,18 @@ get_list(char *path) {
SKIP_SPACE(matches[i]);
if (*(matches[i])) {
list = g_slist_prepend(list, matches[i]);
+ installed++;
}
}
}
if (list != NULL) {
list = g_slist_sort(list, (GCompareFunc)g_strcmp0);
- ret = g_malloc_n(installed + 1, sizeof(char*));
+ ret = g_new(char*, installed+1);
int i=0;
for (GSList *l = list; l; l=l->next)
- ret[i++] = l->data;
+ ret[i++] = g_strdup(l->data);
ret[i] = NULL;
+ g_slist_free(list);
}
g_strfreev(matches);
g_free(content);
@@ -701,6 +703,7 @@ cl_list_installed(int flags) {
for (int i=0; list[i]; i++) {
printf(" * %s\n", list[i]);
}
+ g_strfreev(list);
}
else
notify("No extensions installed");
@@ -714,6 +717,7 @@ cl_list_all(int flags) {
for (int i=0; list[i]; i++) {
printf(" * %s\n", list[i]);
}
+ g_strfreev(list);
}
else
notify("No extensions installed");