diff options
author | Brad King <brad.king@kitware.com> | 2018-05-14 15:49:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-05-14 15:54:27 (GMT) |
commit | 6e594916592e5f8f17b387546d79e484ac092b9e (patch) | |
tree | e063592913180cd287c58e92ad1795fd734bc74c /Source | |
parent | fbe6cd1596bf280edd49aeb8f981f99d7cd8beb3 (diff) | |
download | CMake-6e594916592e5f8f17b387546d79e484ac092b9e.zip CMake-6e594916592e5f8f17b387546d79e484ac092b9e.tar.gz CMake-6e594916592e5f8f17b387546d79e484ac092b9e.tar.bz2 |
add_custom_{command,target}: Fix crash on empty expanded command
Our custom command generation logic assumes that all command lines have
at least `argv0`. In `add_custom_{command,target}` we already check
that at least a `COMMAND` was given, but using `COMMAND_EXPAND_LISTS` in
combination with a generator expression that expands to an empty string
may produce an empty command line. In this case simply add an empty
string as a command to maintain our internal invariant.
Fixes: #17993
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCustomCommandGenerator.cxx | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 136cf39..6c9f9d6 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -40,6 +40,14 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, argv.push_back(std::move(parsed_arg)); } } + + // Later code assumes at least one entry exists, but expanding + // lists on an empty command may have left this empty. + // FIXME: Should we define behavior for removing empty commands? + if (argv.empty()) { + argv.push_back(std::string()); + } + this->CommandLines.push_back(std::move(argv)); } |