diff --git a/configure.ac b/configure.ac index 6fd53c511..706a69bcf 100644 --- a/configure.ac +++ b/configure.ac @@ -389,6 +389,20 @@ else AC_MSG_RESULT(no) fi +# Check if we are using basic BSD curses - in that case we redefine +# del_curterm as a no-op, to avoid a double-free + +AC_MSG_CHECKING([If we are using BSD curses]) +case $target_os in + *bsd*) + AC_MSG_RESULT(yes) + AC_CHECK_LIB( ncurses, del_curterm, true, [AC_DEFINE([HAVE_BROKEN_DEL_CURTERM],[1],[We are using basic BSD curses, redefine del_curterm to a no-op to avoid a double-free bug])]) + ;; + *) + AC_MSG_RESULT(no) + ;; +esac + # Tell the world what we know AC_CONFIG_FILES([Makefile fish.spec doc_src/fish.1 doc_src/Doxyfile etc/fish etc/fish_interactive.fish share/fish seq]) AC_OUTPUT diff --git a/fallback.c b/fallback.c index d98eb0360..3024ae2c6 100644 --- a/fallback.c +++ b/fallback.c @@ -997,3 +997,11 @@ wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz) #endif +#ifdef HAVE_BROKEN_DEL_CURTERM + +int del_curterm(TERMINAL *oterm) +{ +} + +#endif + diff --git a/fallback.h b/fallback.h index e3952ec3a..10a071213 100644 --- a/fallback.h +++ b/fallback.h @@ -271,4 +271,12 @@ size_t wcslcpy( wchar_t *dst, const wchar_t *src, size_t siz ); #endif +#ifdef HAVE_BROKEN_DEL_CURTERM + +/** + BSD del_curterm seems to do a double-free. We redefine it as a no-op +*/ +int del_curterm(TERMINAL *oterm); +#endif + #endif