浏览代码

KWSys: Correctly handle empty environment variables

Fix a crash which occurs when SystemTools::GetPath attempts to process
an empty environment variable.

Author: Vladimir Panteleev <[email protected]>
Brad King 14 年之前
父节点
当前提交
c544545c63
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Source/kwsys/SystemTools.cxx

+ 1 - 1
Source/kwsys/SystemTools.cxx

@@ -326,7 +326,7 @@ void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char
   kwsys_stl::string pathEnv = cpathEnv;
 
   // A hack to make the below algorithm work.
-  if(pathEnv[pathEnv.length()-1] != ':')
+  if(!pathEnv.empty() && pathEnv[pathEnv.length()-1] != pathSep[0])
     {
     pathEnv += pathSep;
     }