summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-04-10 17:14:02 (GMT)
committerBrad King <brad.king@kitware.com>2018-04-10 19:00:37 (GMT)
commit6f2701abf60bc8c0aeed14e09adf28d59023da87 (patch)
tree85143259d399ae5ed7718f2cec36aa1d9b15fef1 /Source/CPack
parent61fd4c742013a7f9139db190f936703b656540ff (diff)
downloadCMake-6f2701abf60bc8c0aeed14e09adf28d59023da87.zip
CMake-6f2701abf60bc8c0aeed14e09adf28d59023da87.tar.gz
CMake-6f2701abf60bc8c0aeed14e09adf28d59023da87.tar.bz2
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
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cpack.cxx8
1 files changed, 4 insertions, 4 deletions
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 507a10c..b6ff38b 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -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