From 1f4aeb1739fb632ab5162a977764b51736728edc Mon Sep 17 00:00:00 2001
From: Fujii Hironori <Hironori.Fujii@sony.com>
Date: Fri, 26 Aug 2016 15:28:48 +0900
Subject: VS: Fix out-of-bounds write on empty Nsight Tegra version

In cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator,
wrote 0 to this->NsightTegraVersion[-1] if sscanf returns -1 which is
the case of GetNsightTegraVersion is empty.
---
 Source/cmVisualStudio10TargetGenerator.cxx | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index fb05976..009f9a2 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -183,13 +183,12 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
   this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
   this->Platform = gg->GetPlatformName();
   this->NsightTegra = gg->IsNsightTegra();
-  for (int i =
-         sscanf(gg->GetNsightTegraVersion().c_str(), "%u.%u.%u.%u",
-                &this->NsightTegraVersion[0], &this->NsightTegraVersion[1],
-                &this->NsightTegraVersion[2], &this->NsightTegraVersion[3]);
-       i < 4; ++i) {
+  for (int i = 0; i < 4; ++i) {
     this->NsightTegraVersion[i] = 0;
   }
+  sscanf(gg->GetNsightTegraVersion().c_str(), "%u.%u.%u.%u",
+         &this->NsightTegraVersion[0], &this->NsightTegraVersion[1],
+         &this->NsightTegraVersion[2], &this->NsightTegraVersion[3]);
   this->MSTools = !this->NsightTegra;
   this->TargetCompileAsWinRT = false;
   this->BuildFileStream = 0;
-- 
cgit v0.12