From 5722d2ea4ca3eec0fe53f96e166d03df8cdb5c07 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <lfleischer@calcurse.org>
Date: Fri, 28 Jul 2017 16:02:07 +0200
Subject: Fix segmentation fault when changing colors

The pair_content() function can be used to retrieve a color pair. The
foreground and the background color numbers are written to addresses
specified by the second and third parameters. While both parameters were
optional in older ncurses implementations (making it possible to pass
NULL pointers if the one does not care about either foreground or
background color), recent implementations seem to assume that both
parameters are valid pointers. Thus, instead of passing NULL, we need to
pass a pointer to a dummy variable when we do not care about the
background color.

Partly fixes GitHub issue #31.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
---
 src/custom.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src')

diff --git a/src/custom.c b/src/custom.c
index 09f650b..e7e5d5b 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -349,7 +349,7 @@ display_color_config(struct window *cwin, int *mark_fore, int *mark_back,
 	enum { YPOS, XPOS, NBPOS };
 	unsigned i;
 	int pos[SIZE][NBPOS];
-	short colr_fore, colr_back;
+	short colr_fore, colr_back, dummy;
 	int colr[SIZE] = {
 		COLR_RED, COLR_GREEN, COLR_YELLOW, COLR_BLUE,
 		COLR_MAGENTA, COLR_CYAN, COLR_DEFAULT,
@@ -366,10 +366,10 @@ display_color_config(struct window *cwin, int *mark_fore, int *mark_back,
 
 	if (colorize) {
 		if (theme_changed) {
-			pair_content(colr[*mark_fore], &colr_fore, 0L);
+			pair_content(colr[*mark_fore], &colr_fore, &dummy);
 			if (colr_fore == 255)
 				colr_fore = -1;
-			pair_content(colr[*mark_back], &colr_back, 0L);
+			pair_content(colr[*mark_back], &colr_back, &dummy);
 			if (colr_back == 255)
 				colr_back = -1;
 			init_pair(COLR_CUSTOM, colr_fore, colr_back);
-- 
cgit v1.2.3-70-g09d2