CPackIFWInstaller: Avoid potential null pointer dereference

In d16830324f (CPackIFW: Improve warning and docs for show page list
option, 2021-02-14), code was added to report the current QtIFW version.
That code didn't check that there was a Generator object before using it,
resulting in a scanbuild warning about a potential null pointer dereference.
Add a check and output a more general warning message if we don't have
the current QtIFW version available to report.
This commit is contained in:
Craig Scott
2021-02-19 17:11:53 +11:00
parent 50fc9d5b45
commit 90c2f138ee

View File

@@ -186,13 +186,20 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
this->WizardShowPageList.clear(); this->WizardShowPageList.clear();
} }
} else { } else {
std::string currentVersionMsg;
if (this->Generator) {
currentVersionMsg =
"QtIFW version " + this->Generator->FrameworkVersion;
} else {
currentVersionMsg = "an older QtIFW version";
}
cmCPackIFWLogger( cmCPackIFWLogger(
WARNING, WARNING,
"Option CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST is set to \"" "Option CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST is set to \""
<< option << option
<< "\", but it is only supported with QtIFW version 4.0 or later. " << "\", but it is only supported with QtIFW version 4.0 or later. "
"It is being ignored because you are using QtIFW version " "It is being ignored because you are using "
<< this->Generator->FrameworkVersion.data() << std::endl); << currentVersionMsg << std::endl);
} }
} }