diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-08-24 18:04:02 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2019-08-24 18:04:02 +0200 |
commit | 726eee2a66babfa12fc698e82524e05082552276 (patch) | |
tree | f387e680bff6d4f19821dba8136f312c10fdcd6a | |
parent | 77392e4dc611a83845e52dc91129ecb789ad69ee (diff) | |
download | profani-tty-726eee2a66babfa12fc698e82524e05082552276.tar.gz |
Make sure memory in color_pair_cache_reset() was allocated.
Just to be on the safe side. Probably only relevant for unit tests where ncurses vars are not initialized with real values. Fix unit tests on all platforms.
-rw-r--r-- | src/config/color.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/config/color.c b/src/config/color.c index b5df3d2f..8ece8498 100644 --- a/src/config/color.c +++ b/src/config/color.c @@ -371,11 +371,14 @@ void color_pair_cache_reset(void) cache.capacity = 8; cache.pairs = g_malloc0(sizeof(*cache.pairs)*cache.capacity); - - /* default_default */ - cache.pairs[0].fg = -1; - cache.pairs[0].bg = -1; - cache.size = 1; + if (cache.pairs) { + /* default_default */ + cache.pairs[0].fg = -1; + cache.pairs[0].bg = -1; + cache.size = 1; + } else { + log_error("Color: unable to allocate memory"); + } } /** |