diff options
author | Jason Woofenden <jason@jasonwoof.com> | 2012-06-03 14:36:31 +0200 |
---|---|---|
committer | Jason Woofenden <jason@jasonwoof.com> | 2012-06-03 14:36:31 +0200 |
commit | 7d16a438ca96e276d96cce145ac60057183c5fef (patch) | |
tree | 2fc22e2951b52483e2eb5168f41a969bcdcbc897 /src | |
parent | b868f492968ddd575174265f071393ce2a3d926a (diff) | |
download | dwb-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.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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)); |