From a8ca5aea946e1154b4518ba28db3f4e695dbf165 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Aug 2019 10:51:12 -0400 Subject: cmMakefileTargetGenerator: Check for null before using a pointer Fix the order of logic added by commit 7740ccd1a4 (ENH: some cleanup of the makefile generator, 2006-02-14, v2.4.0~517) to check for allocation failure ('new' returns null) before using the pointer. Issue: #19610 --- Source/cmMakefileTargetGenerator.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f35df32..0f13540 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -131,10 +131,10 @@ void cmMakefileTargetGenerator::CreateRuleFile() this->BuildFileStream = new cmGeneratedFileStream(this->BuildFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); - this->BuildFileStream->SetCopyIfDifferent(true); if (!this->BuildFileStream) { return; } + this->BuildFileStream->SetCopyIfDifferent(true); this->LocalGenerator->WriteDisclaimer(*this->BuildFileStream); if (this->GlobalGenerator->AllowDeleteOnError()) { std::vector no_depends; @@ -300,10 +300,10 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() this->FlagFileStream = new cmGeneratedFileStream(this->FlagFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); - this->FlagFileStream->SetCopyIfDifferent(true); if (!this->FlagFileStream) { return; } + this->FlagFileStream->SetCopyIfDifferent(true); this->LocalGenerator->WriteDisclaimer(*this->FlagFileStream); // Include the flags for the target. @@ -1033,10 +1033,10 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() this->InfoFileNameFull = this->LocalGenerator->ConvertToFullPath(this->InfoFileNameFull); this->InfoFileStream = new cmGeneratedFileStream(this->InfoFileNameFull); - this->InfoFileStream->SetCopyIfDifferent(true); - if (!*this->InfoFileStream) { + if (!this->InfoFileStream) { return; } + this->InfoFileStream->SetCopyIfDifferent(true); this->LocalGenerator->WriteDependLanguageInfo(*this->InfoFileStream, this->GeneratorTarget); -- cgit v0.12