diff options
-rw-r--r-- | src/commands.c | 5 | ||||
-rw-r--r-- | src/util.c | 28 | ||||
-rw-r--r-- | src/view.c | 4 |
3 files changed, 21 insertions, 16 deletions
diff --git a/src/commands.c b/src/commands.c index 9a5778ec..67d16d78 100644 --- a/src/commands.c +++ b/src/commands.c @@ -334,14 +334,15 @@ commands_open(KeyMap *km, Arg *arg) { if (dwb.state.nv & OPEN_NORMAL) dwb_set_open_mode(arg->n & ~SET_URL); - dwb.state.type = arg->i; + if (arg) + dwb.state.type = arg->i; if (arg && arg->p && ! (arg->n & SET_URL)) { dwb_load_uri(NULL, arg->p); } else { entry_focus(); - if (arg->n & SET_URL) + if (arg && (arg->n & SET_URL)) entry_set_text(arg->p ? arg->p : CURRENT_URL()); } return STATUS_OK; @@ -101,19 +101,20 @@ dwb_modmask_to_string(guint modmask) { /* util_keyval_to_char (guint keyval) return: char * (alloc) {{{*/ char * util_keyval_to_char(guint keyval, gboolean ignore_whitespace) { - char *key = dwb_malloc(6); + char *key = NULL; guint32 unichar; int length; if ( (unichar = gdk_keyval_to_unicode(keyval)) ) { if (ignore_whitespace && !g_unichar_isgraph(unichar)) - goto error_out; - if ( (length = g_unichar_to_utf8(unichar, key))) { + return NULL; + key = dwb_malloc(6); + if ( key && (length = g_unichar_to_utf8(unichar, key))) { memset(&key[length], '\0', 6-length); return key; } + else + FREE(key); } -error_out: - FREE(key); return NULL; }/*}}}*/ @@ -514,9 +515,11 @@ dwb_navigation_new_from_line(const char *text) { /* dwb_navigation_free(Navigation *n){{{*/ void dwb_navigation_free(Navigation *n) { - FREE(n->first); - FREE(n->second); - FREE(n); + if (n != NULL) { + FREE(n->first); + FREE(n->second); + g_free(n); + } }/*}}}*/ /*}}}*/ /* QUICKMARK {{{*/ @@ -549,10 +552,11 @@ dwb_quickmark_new_from_line(const char *line) { /* dwb_quickmark_free(Quickmark *q) {{{*/ void dwb_quickmark_free(Quickmark *q) { - FREE(q->key); - dwb_navigation_free(q->nav); - FREE(q); - + if (q != NULL) { + FREE(q->key); + dwb_navigation_free(q->nav); + g_free(q); + } }/*}}}*/ /*}}}*/ @@ -887,8 +887,8 @@ view_remove(GList *gl) { if (v->status->style) { g_object_unref(v->status->style); } - FREE(v->status); - FREE(v); + g_free(v->status); + g_free(v); dwb.state.views = g_list_delete_link(dwb.state.views, gl); gl = NULL; |