Fix memory leaks
This commit is contained in:
parent
f8e1e330b2
commit
61ce42a7e2
1
dbus.c
1
dbus.c
@ -294,6 +294,7 @@ static void onNotify(GDBusConnection * connection,
|
|||||||
n->actions = actions;
|
n->actions = actions;
|
||||||
} else {
|
} else {
|
||||||
n->actions = NULL;
|
n->actions = NULL;
|
||||||
|
g_strfreev(actions->actions);
|
||||||
free(actions);
|
free(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
menu.c
8
menu.c
@ -190,10 +190,12 @@ void context_menu(void)
|
|||||||
int parent_io[2];
|
int parent_io[2];
|
||||||
if (pipe(child_io) != 0) {
|
if (pipe(child_io) != 0) {
|
||||||
PERR("pipe()", errno);
|
PERR("pipe()", errno);
|
||||||
|
free(dmenu_input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pipe(parent_io) != 0) {
|
if (pipe(parent_io) != 0) {
|
||||||
PERR("pipe()", errno);
|
PERR("pipe()", errno);
|
||||||
|
free(dmenu_input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pid = fork();
|
int pid = fork();
|
||||||
@ -222,8 +224,10 @@ void context_menu(void)
|
|||||||
close(child_io[1]);
|
close(child_io[1]);
|
||||||
|
|
||||||
size_t len = read(parent_io[0], buf, 1023);
|
size_t len = read(parent_io[0], buf, 1023);
|
||||||
if (len == 0)
|
if (len == 0) {
|
||||||
|
free(dmenu_input);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int status;
|
int status;
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
@ -232,5 +236,7 @@ void context_menu(void)
|
|||||||
close(parent_io[0]);
|
close(parent_io[0]);
|
||||||
|
|
||||||
dispatch_menu_result(buf);
|
dispatch_menu_result(buf);
|
||||||
|
|
||||||
|
free(dmenu_input);
|
||||||
}
|
}
|
||||||
/* vim: set ts=8 sw=8 tw=0: */
|
/* vim: set ts=8 sw=8 tw=0: */
|
||||||
|
@ -155,6 +155,12 @@ void notification_free(notification * n)
|
|||||||
free(n->icon);
|
free(n->icon);
|
||||||
free(n->msg);
|
free(n->msg);
|
||||||
free(n->dbus_client);
|
free(n->dbus_client);
|
||||||
|
|
||||||
|
if (n->actions) {
|
||||||
|
g_strfreev(n->actions->actions);
|
||||||
|
free(n->actions->dmenu_str);
|
||||||
|
}
|
||||||
|
|
||||||
free(n);
|
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); // kill square brackets
|
||||||
string_replace_char(']', ')', human_readable);
|
string_replace_char(']', ')', human_readable);
|
||||||
|
|
||||||
n->actions->dmenu_str =
|
char *act_str = g_strdup_printf("#%s [%s]", human_readable, n->appname);
|
||||||
string_append(n->actions->dmenu_str,
|
if (act_str) {
|
||||||
g_strdup_printf("#%s [%s]", human_readable,
|
n->actions->dmenu_str = string_append(n->actions->dmenu_str, act_str, "\n");
|
||||||
n->appname),
|
free(act_str);
|
||||||
"\n");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,9 @@ static int ini_get_urgency(char *section, char *key, int def)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"unknown urgency: %s, ignoring\n",
|
"unknown urgency: %s, ignoring\n",
|
||||||
urg);
|
urg);
|
||||||
free(urg);
|
|
||||||
}
|
}
|
||||||
|
if (urg)
|
||||||
|
free(urg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user