bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] On builds without ext-colors, clamp the number of color pairs


From: David Benjamin
Subject: [PATCH] On builds without ext-colors, clamp the number of color pairs
Date: Sun, 17 Jul 2011 21:04:53 -0400

Otherwise applications may allocate values too high and stomp over other
attribute bits.
---
 ncurses/base/lib_color.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/ncurses/base/lib_color.c b/ncurses/base/lib_color.c
index 50d580e..e72f068 100644
--- a/ncurses/base/lib_color.c
+++ b/ncurses/base/lib_color.c
@@ -332,6 +332,14 @@ NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
                                 NCURSES_SP_NAME(_nc_outch));
        }
 
+#ifndef NCURSES_EXT_COLORS
+       /*
+        * Without ext-colors, we cannot represent more than 256 color pairs.
+        */
+       if (maxpairs > 256)
+           maxpairs = 256;
+#endif
+
        if (maxpairs > 0 && maxcolors > 0) {
            SP_PARM->_pair_limit = maxpairs;
 
-- 
1.7.6.179.gc850




reply via email to

[Prev in Thread] Current Thread [Next in Thread]