about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-08-24 18:04:02 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-08-24 18:04:02 +0200
commit726eee2a66babfa12fc698e82524e05082552276 (patch)
treef387e680bff6d4f19821dba8136f312c10fdcd6a /src/config
parent77392e4dc611a83845e52dc91129ecb789ad69ee (diff)
downloadprofani-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.
Diffstat (limited to 'src/config')
-rw-r--r--src/config/color.c13
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");
+    }
 }
 
 /**