diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 28 |
1 files changed, 16 insertions, 12 deletions
@@ -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); + } }/*}}}*/ /*}}}*/ |