summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2017-07-28 16:02:07 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2017-07-28 16:02:46 +0200
commit5722d2ea4ca3eec0fe53f96e166d03df8cdb5c07 (patch)
tree90d6848e1c87ebde1fc5d0ee5b6755e7c6e5dc2c /src
parent5aa7a0962a2728e6b2164c4531d3995b33cb71b8 (diff)
downloadcalcurse-5722d2ea4ca3eec0fe53f96e166d03df8cdb5c07.tar.gz
calcurse-5722d2ea4ca3eec0fe53f96e166d03df8cdb5c07.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/custom.c6
1 files changed, 3 insertions, 3 deletions
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);