summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Woofenden <jason@jasonwoof.com>2012-06-03 14:36:31 +0200
committerJason Woofenden <jason@jasonwoof.com>2012-06-03 14:36:31 +0200
commit7d16a438ca96e276d96cce145ac60057183c5fef (patch)
tree2fc22e2951b52483e2eb5168f41a969bcdcbc897 /src
parentb868f492968ddd575174265f071393ce2a3d926a (diff)
downloaddwb-7d16a438ca96e276d96cce145ac60057183c5fef.zip
init_custom_keys: fix mem leaks, parse carefully
Don't leak memory on early exit. Be careful about little things like EOL after \ or : --- src/dwb.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
Diffstat (limited to 'src')
-rw-r--r--src/dwb.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/dwb.c b/src/dwb.c
index 216c3f16..a3c3cf24 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -3710,20 +3710,30 @@ dwb_init_custom_keys(gboolean reload) {
CustomCommand *command;
for (int i=0; lines[i]; i++) {
- keybuf = g_string_new(NULL);
if (! *lines[i])
continue;
+ keybuf = g_string_new(NULL);
current_line = lines[i];
while (*current_line && *current_line != ':') {
- if (*current_line == '\\')
+ if (*current_line == '\\') {
current_line++;
+ if (!*current_line) {
+ continue;
+ }
+ }
g_string_append_c(keybuf, *current_line);
current_line++;
}
- if (*current_line != ':')
+ if (*current_line != ':') {
+ g_string_free(keybuf, true);
continue;
+ }
current_line++;
+ if (!*current_line) {
+ g_string_free(keybuf, true);
+ continue;
+ }
command = dwb_malloc(sizeof(CustomCommand));
command->key = dwb_malloc(sizeof(Key));