summaryrefslogtreecommitdiff
path: root/src/ToolBox/superpmi/superpmi-shared/spmiutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ToolBox/superpmi/superpmi-shared/spmiutil.cpp')
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/spmiutil.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/spmiutil.cpp b/src/ToolBox/superpmi/superpmi-shared/spmiutil.cpp
index dd72659485..986c6d1f5e 100644
--- a/src/ToolBox/superpmi/superpmi-shared/spmiutil.cpp
+++ b/src/ToolBox/superpmi/superpmi-shared/spmiutil.cpp
@@ -181,7 +181,11 @@ WCHAR* getResultFileName(const WCHAR* folderPath, WCHAR* executableName, const W
const size_t maxAcceptablePathLength =
MAX_PATH - 50; // subtract 50 because excel doesn't like paths longer then 230.
- if (dataFileNameLength > maxAcceptablePathLength)
+#ifdef FEATURE_PAL
+ assert(executableNameLength == 0);
+#endif // FEATURE_PAL
+
+ if (dataFileNameLength > maxAcceptablePathLength || executableNameLength == 0)
{
// The path name is too long; creating the file will fail. This can happen because we use the command line,
// which for ngen includes lots of environment variables, for example.
@@ -189,6 +193,8 @@ WCHAR* getResultFileName(const WCHAR* folderPath, WCHAR* executableName, const W
const size_t randStringLength = 8;
+#ifndef FEATURE_CORECLR
+
size_t lengthToBeDeleted = (dataFileNameLength - maxAcceptablePathLength) + randStringLength;
if (executableNameLength <= lengthToBeDeleted)
@@ -201,6 +207,8 @@ WCHAR* getResultFileName(const WCHAR* folderPath, WCHAR* executableName, const W
executableNameLength -= lengthToBeDeleted;
executableName[executableNameLength] = 0;
+#endif // FEATURE_CORECLR
+
executableNameLength += randStringLength;
WCHAR randNumberString[randStringLength + 1];
generateRandomSuffix(randNumberString, randStringLength + 1);