diff --git a/SystemTools.cxx b/SystemTools.cxx
index 85ea807f1f5ad3c25d17dfce23e64e414a01d226..e5d259cc7944d86b730ec9f4c5947f86d69a5780 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -4008,22 +4008,22 @@ bool SystemTools::FileIsFullPath(const char* in_name)
   return false;
 }
 
-bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath)
+bool SystemTools::GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& shortPath)
 {
 #if defined(WIN32) && !defined(__CYGWIN__)
-  const int size = int(strlen(path)) +1; // size of return
+  const int size = int(path.size()) +1; // size of return
   char *tempPath = new char[size];  // create a buffer
   DWORD ret;
 
   // if the path passed in has quotes around it, first remove the quotes
-  if (path[0] == '"' && path[strlen(path)-1] == '"')
+  if (!path.empty() && path[0] == '"' && *path.rbegin() == '"')
     {
-    strcpy(tempPath,path+1);
-    tempPath[strlen(tempPath)-1] = '\0';
+    strcpy(tempPath,path.c_str()+1);
+    tempPath[size-2] = '\0';
     }
   else
     {
-    strcpy(tempPath,path);
+    strcpy(tempPath,path.c_str());
     }
 
   kwsys_stl::wstring wtempPath = Encoding::ToWide(tempPath);
diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in
index 9457a4e3455a9d99ef3dca79d535b130b994dc9b..e43ff982c2d52b6bc2ab481093f2d10fb0de5a14 100644
--- a/SystemTools.hxx.in
+++ b/SystemTools.hxx.in
@@ -465,7 +465,7 @@ public:
    * For windows return the short path for the given path,
    * Unix just a pass through
    */
-  static bool GetShortPath(const char* path, kwsys_stl::string& result);
+  static bool GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& result);
   
   /**
    * Read line from file. Make sure to get everything. Due to a buggy stream