Index: Lex/HeaderSearch.cpp
===================================================================
--- Lex/HeaderSearch.cpp	(revision 47533)
+++ Lex/HeaderSearch.cpp	(working copy)
@@ -228,7 +228,20 @@
     if (const FileEntry *FE = FileMgr.getFile(TmpDir.begin(), TmpDir.end())) {
       // Leave CurDir unset.
       // This file is a system header or C++ unfriendly if the old file is.
-      getFileInfo(FE).DirInfo = getFileInfo(CurFileEnt).DirInfo;
+      
+      // Note: Don't use: getFileInfo(FE).DirInfo = getFileInfo(CurFileEnt).DirInfo;
+      // MSVC, behind the scenes, does this:
+
+      // PerFileInfo &pf1 = getFileInfo(CurFileEnt);
+      // PerFileInfo &pf2 = getFileInfo(FE);
+      // pf2.DirInfo = pf1.DirInfo
+
+      // The problem is that if there's a resize() of the FileInfo vector during
+      // the getFileInfo(FE) call, pf1 will point to invalid data.
+
+      // Make the assignment explicit
+      unsigned int tmp = getFileInfo(CurFileEnt).DirInfo;
+      getFileInfo(FE).DirInfo = tmp;
       return FE;
     }
   }
@@ -357,7 +370,20 @@
   }
   
   // This file is a system header or C++ unfriendly if the old file is.
-  getFileInfo(FE).DirInfo = getFileInfo(ContextFileEnt).DirInfo;
+
+  // Note: Don't use: getFileInfo(FE).DirInfo = getFileInfo(ContextFileEnt).DirInfo;
+  // MSVC, behind the scenes, does this:
+
+  // PerFileInfo &pf1 = getFileInfo(ContextFileEnt);
+  // PerFileInfo &pf2 = getFileInfo(FE);
+  // pf2.DirInfo = pf1.DirInfo
+
+  // The problem is that if there's a resize() of the FileInfo vector during
+  // the getFileInfo(FE) call, pf1 will point to invalid data.
+
+  // Make the assignment explicit
+  unsigned int tmp = getFileInfo(ContextFileEnt).DirInfo;
+  getFileInfo(FE).DirInfo = tmp;
   return FE;
 }
 
