Merge pull request #217 from dorkster/master

Fix memory leaks
This commit is contained in:
Sascha Kruse 2015-03-05 12:02:36 +01:00
commit 08fa6ea998
4 changed files with 21 additions and 7 deletions

1
dbus.c
View File

@ -294,6 +294,7 @@ static void onNotify(GDBusConnection * connection,
n->actions = actions;
} else {
n->actions = NULL;
g_strfreev(actions->actions);
free(actions);
}

8
menu.c
View File

@ -190,10 +190,12 @@ void context_menu(void)
int parent_io[2];
if (pipe(child_io) != 0) {
PERR("pipe()", errno);
free(dmenu_input);
return;
}
if (pipe(parent_io) != 0) {
PERR("pipe()", errno);
free(dmenu_input);
return;
}
int pid = fork();
@ -222,8 +224,10 @@ void context_menu(void)
close(child_io[1]);
size_t len = read(parent_io[0], buf, 1023);
if (len == 0)
if (len == 0) {
free(dmenu_input);
return;
}
int status;
waitpid(pid, &status, 0);
@ -232,5 +236,7 @@ void context_menu(void)
close(parent_io[0]);
dispatch_menu_result(buf);
free(dmenu_input);
}
/* vim: set ts=8 sw=8 tw=0: */

View File

@ -155,6 +155,12 @@ void notification_free(notification * n)
free(n->icon);
free(n->msg);
free(n->dbus_client);
if (n->actions) {
g_strfreev(n->actions->actions);
free(n->actions->dmenu_str);
}
free(n);
}
@ -480,11 +486,11 @@ int notification_init(notification * n, int id)
string_replace_char('[', '(', human_readable); // kill square brackets
string_replace_char(']', ')', human_readable);
n->actions->dmenu_str =
string_append(n->actions->dmenu_str,
g_strdup_printf("#%s [%s]", human_readable,
n->appname),
"\n");
char *act_str = g_strdup_printf("#%s [%s]", human_readable, n->appname);
if (act_str) {
n->actions->dmenu_str = string_append(n->actions->dmenu_str, act_str, "\n");
free(act_str);
}
}
}

View File

@ -47,8 +47,9 @@ static int ini_get_urgency(char *section, char *key, int def)
fprintf(stderr,
"unknown urgency: %s, ignoring\n",
urg);
free(urg);
}
if (urg)
free(urg);
return ret;
}