Fix AV in corerun on invalid filename
authorJan Kotas <jkotas@microsoft.com>
Wed, 13 Sep 2017 03:32:08 +0000 (20:32 -0700)
committerJan Kotas <jkotas@microsoft.com>
Wed, 13 Sep 2017 17:08:32 +0000 (10:08 -0700)
Before this fix, corerun would AV on certain invalid paths e.g.: corerun test.exe\

src/coreclr/hosts/corerun/corerun.cpp

index a9e3b66..814aac9 100644 (file)
@@ -402,7 +402,7 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo
         appPathPtr = appPath.OpenUnicodeBuffer(size - 1);
         length = WszGetFullPathName(exeName, size, appPathPtr, &filePart);
     }
-    if (length == 0 || length >= size) {
+    if (length == 0 || length >= size || filePart == NULL) {
         log << W("Failed to get full path: ") << exeName << Logger::endl;
         log << W("Error code: ") << GetLastError() << Logger::endl;
         return false;