Hi, I've been trying to utilise the alloc_pair function in a terminal multiplexer program to support direct colours. The problem I'm facing is that alloc_pair never reallocates once allocated pairs, be they freed or not, causing segfault and/or returning only ERRs, after it can no longer provide a larger pair index.
Looking around the ncurses source code and playing around with tracing, it would appear alloc_pair always successfully finds a new usable index in the first for loop, as SP_PARM->_pair_alloc seems to grow dynamically without apparent limit. COLOR_PAIRS equals to 65536, as expected, but alloc_pair keeps going past it, returning 69949 valid pairs, no errors, on the latest test run, before causing a segfault. Some earlier test runs ended up with sequential ERR returns before reaching the breaking call, assumably until SP_PARM->_recent_pair grew large enough to cause a segfault, by some means unknown to me. In any case, it would appear the function requires some reworking. I was using ncurses v6.5 on st with a custom st-direct terminfo entry with RGB, colors, pairs and setaf/b set accordingly, on Void Linux. Ingvix
