about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-08-23 14:54:55 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-08-23 14:54:55 +0200
commite408e988a76de24a9872a2a8047594eb2270f017 (patch)
treec62d64bbfe26e600d8cae1794fdead5d104c70e2
parentbad244fc9508644beb655816e7f7b58ec7bd6a6d (diff)
downloadprofani-tty-e408e988a76de24a9872a2a8047594eb2270f017.tar.gz
color: set capacity in unittest case
Fix https://github.com/profanity-im/profanity/issues/1178
-rw-r--r--src/config/color.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/config/color.c b/src/config/color.c
index d80b2b36..b5df3d2f 100644
--- a/src/config/color.c
+++ b/src/config/color.c
@@ -365,6 +365,11 @@ void color_pair_cache_reset(void)
      * compile-time constant
      */
     cache.capacity = COLOR_PAIRS;
+
+    /* when we run unit tests COLOR_PAIRS will be -1 */
+    if (cache.capacity < 0)
+        cache.capacity = 8;
+
     cache.pairs = g_malloc0(sizeof(*cache.pairs)*cache.capacity);
 
     /* default_default */