mirror of
https://github.com/reactos/CMake.git
synced 2024-11-27 21:41:03 +00:00
CPack: Fix crash on invalid generator name
In commit v3.11.0-rc1~68^2 (CPack: accept --trace and --trace-expand, 2017-12-09) a nullptr dereference was added that occurs when `cpack -G NotAGenerator` is invoked. Add the needed condition. Fixes: #17900
This commit is contained in:
parent
61fd4c7420
commit
6f2701abf6
@ -350,16 +350,16 @@ int main(int argc, char const* const* argv)
|
||||
}
|
||||
if (parsed) {
|
||||
cpackGenerator = generators.NewGenerator(gen);
|
||||
if (!cpackGenerator) {
|
||||
if (cpackGenerator) {
|
||||
cpackGenerator->SetTrace(trace);
|
||||
cpackGenerator->SetTraceExpand(traceExpand);
|
||||
} else {
|
||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||
"Cannot initialize CPack generator: " << gen
|
||||
<< std::endl);
|
||||
parsed = 0;
|
||||
}
|
||||
|
||||
cpackGenerator->SetTrace(trace);
|
||||
cpackGenerator->SetTraceExpand(traceExpand);
|
||||
|
||||
if (parsed && !cpackGenerator->Initialize(gen, mf)) {
|
||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||
"Cannot initialize the generator " << gen
|
||||
|
@ -335,6 +335,7 @@ add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
|
||||
add_RunCMake_test(CommandLineTar)
|
||||
|
||||
add_RunCMake_test(install)
|
||||
add_RunCMake_test(CPackCommandLine)
|
||||
add_RunCMake_test(CPackConfig)
|
||||
add_RunCMake_test(CPackInstallProperties)
|
||||
add_RunCMake_test(ExternalProject)
|
||||
|
1
Tests/RunCMake/CPackCommandLine/NotAGenerator-result.txt
Normal file
1
Tests/RunCMake/CPackCommandLine/NotAGenerator-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
1
Tests/RunCMake/CPackCommandLine/NotAGenerator-stderr.txt
Normal file
1
Tests/RunCMake/CPackCommandLine/NotAGenerator-stderr.txt
Normal file
@ -0,0 +1 @@
|
||||
^CPack Error: Cannot initialize CPack generator: NotAGenerator
|
10
Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake
Normal file
10
Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake
Normal file
@ -0,0 +1,10 @@
|
||||
include(RunCMake)
|
||||
set(RunCMake_TEST_TIMEOUT 60)
|
||||
|
||||
file(WRITE "${RunCMake_BINARY_DIR}/NotAGenerator-build/CPackConfig.cmake" [[
|
||||
set(CPACK_PACKAGE_NAME "Test")
|
||||
set(CPACK_PACKAGE_VERSION "1")
|
||||
]])
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
run_cmake_command(NotAGenerator ${CMAKE_CPACK_COMMAND} -G NotAGenerator)
|
||||
unset(RunCMake_TEST_NO_CLEAN)
|
Loading…
Reference in New Issue
Block a user