ccmake crashes if a cache entry has set but empty STRINGS property
ccmake doesn't handle this situation. It assumes option count is greater than zero therefore it doesn't check option count.
For reproducing please follow this steps:
- create a new folder
- create a CMakeLists.txt file in the folder with this content:
cmake_minimum_required(VERSION 3.14.5)
project(prj CXX)
set(THE_VAR CACHE STRING "")
set_property(CACHE THE_VAR PROPERTY STRINGS "")
- run ccmake .
- configure project by pressing 'c' on ccmake.
- go to THE_VAR
- press Enter
- it gives segfault due to trying to access first element of vector which is empty.
I did this for last release (ccmake v3.15.2), and for master branch (which is at 70c56b85 now.) and results are same.
The backtrace:
#0 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign (this=0x6e8ee0,
__str=<error reading variable: Cannot access memory at address 0x28>)
at /usr/src/debug/gcc-9.1.1-1.fc30.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/basic_string.tcc:259
#1 0x00000000005dc16a in cmCursesWidget::SetValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#2 0x00000000005e1888 in cmCursesOptionsWidget::HandleInput(int&, cmCursesMainForm*, _win_st*) ()
#3 0x00000000005e4485 in cmCursesMainForm::HandleInput() ()
#4 0x0000000000416449 in main ()
Edited by Muhammed Furkan USLU