ncurses unconditionally sets NDEBUG to either 0 or 1 in code. include/assert.h disables assert()'s if NDEBUG is set, so assert()'s are never enabled in ncurses. This leads to this report http://scan.freebsd.your.org/freebsd-head/lib.ncurses.menu/2012-09-16-amd64/report-3vc5Zu.html#Path5 and ca. 25 others in ncurses. Fix: Fix this by removing NDEBUG from contrib/ncurses/include/ncurses_defs. The comment at the top of that file even says not to define NDEBUG there, and it's been fixed in ncurses 5.9 which is in the vendor area in SVN. Also remove two instances in lib/ncurses where NDEBUG is set unconditionally. The attached patch allows Clang Analyzer to reason correctly about the code. It's still possible to build ncurses without assert()s by adding -DNDEBUG to CFLAGS when building. I'm assuming that ncurses is not performance-critical in the default use and that enabling assert()s is OK. From a user perspective, it's better to get an assertion error with the real problem than a null pointer dereference error or garbage data. Patch attached with submission follows:
Created attachment 174958 [details] Remove unconditional NDEBUG
For bugs matching the following conditions: - Status == In Progress - Assignee == "bugs@FreeBSD.org" - Last Modified Year <= 2017 Do - Set Status to "Open"