diff options
author | portix <portix@gmx.net> | 2012-01-19 09:46:31 +0100 |
---|---|---|
committer | portix <portix@gmx.net> | 2012-01-19 09:46:31 +0100 |
commit | d93f04c7b9bec2578255ee0c9107bfe331e0c620 (patch) | |
tree | 8ad9f9d835ef01bc5591c1b6120b6e8a63efa7f8 /src/util.c | |
parent | 8e9e2f074ee10f411f54848f390475b5480c572e (diff) | |
download | dwb-d93f04c7b9bec2578255ee0c9107bfe331e0c620.zip |
Fixing redundant checks for NULL reported by cppcheck
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); + } }/*}}}*/ /*}}}*/ |