diff options
author | Brad King <brad.king@kitware.com> | 2017-01-16 15:37:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-01-16 15:47:32 (GMT) |
commit | 2bba0bfc2c113a1ec94802ecfb8a836a385f919b (patch) | |
tree | 46ff211bbbc0920565d7f752927a849c42585b1d | |
parent | 85a8939e2fc7eb2715a9264fd40c009c3a98cb8b (diff) | |
download | CMake-2bba0bfc2c113a1ec94802ecfb8a836a385f919b.zip CMake-2bba0bfc2c113a1ec94802ecfb8a836a385f919b.tar.gz CMake-2bba0bfc2c113a1ec94802ecfb8a836a385f919b.tar.bz2 |
file: Fix crash on GLOB with no expressions after LIST_DIRECTORIES
Since commit v3.3.0-rc1~318^2~1 (file: Teach GLOB to list directories
optionally, 2015-03-17) using `LIST_DIRECTORIES` followed by no
expression causes a crash. Fix the logic to avoid the crash.
Fixes: #16565
-rw-r--r-- | Source/cmFileCommand.cxx | 2 | ||||
-rw-r--r-- | Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file/RunCMakeTest.cmake | 1 |
3 files changed, 3 insertions, 1 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index d10c886..91cecb3 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -788,7 +788,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args, this->SetError("LIST_DIRECTORIES missing bool value."); return false; } - ++i; + continue; } if (recurse && (*i == "FOLLOW_SYMLINKS")) { diff --git a/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES.cmake b/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES.cmake new file mode 100644 index 0000000..37a9d54 --- /dev/null +++ b/Tests/RunCMake/file/GLOB-noexp-LIST_DIRECTORIES.cmake @@ -0,0 +1 @@ +file(GLOB CONTENT_LIST LIST_DIRECTORIES false) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index 48fa757..7497544 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -31,6 +31,7 @@ run_cmake(GLOB_RECURSE) run_cmake(GLOB-error-LIST_DIRECTORIES-not-boolean) # test is valid both for GLOB and GLOB_RECURSE run_cmake(GLOB-error-LIST_DIRECTORIES-no-arg) +run_cmake(GLOB-noexp-LIST_DIRECTORIES) if(NOT WIN32 OR CYGWIN) run_cmake(GLOB_RECURSE-cyclic-recursion) |