diff options
author | Jonas Fonseca <jonas.fonseca@gmail.com> | 2018-05-18 15:54:36 -0400 |
---|---|---|
committer | Jonas Fonseca <jonas.fonseca@gmail.com> | 2018-05-18 15:54:36 -0400 |
commit | 4d045874f50d5fd11eff8c46ac562f0f96156a57 (patch) | |
tree | bbe9834c69713849e6d5bb0cd4f88ea3791b185b | |
parent | acb472d282292730d5e8009e4664985ee58c39e2 (diff) |
Fix #824: Workaround potential null pointer dereferences
-rw-r--r-- | compat/hashtab.c | 2 | ||||
-rw-r--r-- | src/line.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/compat/hashtab.c b/compat/hashtab.c index c4d6361a..3f3171c5 100644 --- a/compat/hashtab.c +++ b/compat/hashtab.c @@ -728,7 +728,7 @@ htab_remove_elt_with_hash (htab_t htab, PTR element, hashval_t hash) PTR *slot; slot = htab_find_slot_with_hash (htab, element, hash, NO_INSERT); - if (*slot == HTAB_EMPTY_ENTRY) + if (!slot || *slot == HTAB_EMPTY_ENTRY) return; if (htab->del_f) @@ -206,8 +206,8 @@ init_colors(void) { struct line_rule query = { "default", STRING_SIZE("default") }; struct line_rule *rule = find_line_rule(&query); - int default_bg = rule->info.bg; - int default_fg = rule->info.fg; + int default_bg = rule ? rule->info.bg : COLOR_BLACK; + int default_fg = rule ? rule->info.fg : COLOR_WHITE; enum line_type type; /* XXX: Even if the terminal does not support colors (e.g. |