From 2c2fbaf0e5902d62a4321cdac125778a2170ec5d Mon Sep 17 00:00:00 2001 From: Mariusz Plucinski Date: Wed, 20 Jun 2012 08:02:00 -0400 Subject: [PATCH] Do not crash on unknown source language (#13323) If a source file extension is not recognized as any language then src.GetLanguage() may return NULL. Check the result before dereferencing in cmLocalGenerator::GetObjectFileNameWithoutTarget. --- Source/cmLocalGenerator.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 13ede5d70..32cfa68cb 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2764,10 +2764,13 @@ cmLocalGenerator bool replaceExt = this->NeedBackwardsCompatibility(2, 4); if(!replaceExt) { - std::string repVar = "CMAKE_"; - repVar += source.GetLanguage(); - repVar += "_OUTPUT_EXTENSION_REPLACE"; - replaceExt = this->Makefile->IsOn(repVar.c_str()); + if(const char* lang = source.GetLanguage()) + { + std::string repVar = "CMAKE_"; + repVar += lang; + repVar += "_OUTPUT_EXTENSION_REPLACE"; + replaceExt = this->Makefile->IsOn(repVar.c_str()); + } } // Remove the source extension if it is to be replaced.