This change fixes an issue caused by recent change in filename buffers
allocations. It was using the operator new, but it should not be used
in PAL since it invokes overriden operator new in the coreclr.
The fix is to use InternalMalloc instead.
Commit migrated from https://github.com/dotnet/coreclr/commit/
d8755f9d7ba419d31cf7ae6e0db6b7d10fafd440
}
}
- tempfile_name = new char[MAX_LONGPATH];
+ tempfile_name = (char*)InternalMalloc(pThread, MAX_LONGPATH);
if (tempfile_name == NULL)
{
pThread->SetLastError(ERROR_NOT_ENOUGH_MEMORY);
path_size = MultiByteToWideChar( CP_ACP, 0, tempfile_name, -1,
lpTempFileName, MAX_LONGPATH );
- delete [] tempfile_name;
+ InternalFree(pThread, tempfile_name);
tempfile_name = NULL;
if (!path_size)
{
BOOL FILEGetFileNameFromSymLink(char *source)
{
int ret;
- char * sLinkData = new char[MAX_LONGPATH];
+ CPalThread* pThread = InternalGetCurrentThread();
+ char * sLinkData = (char*)InternalMalloc(pThread, MAX_LONGPATH);
do
{
}
} while (ret > 0);
- delete [] sLinkData;
+ InternalFree(pThread, sLinkData);
return (errno == EINVAL);
}
// Make sure it's terminated with a slash.
if (g_szCoreCLRPath == NULL)
{
- g_szCoreCLRPath = new char[g_cbszCoreCLRPath/sizeof(char)];
+ CPalThread* pThread = InternalGetCurrentThread();
+ g_szCoreCLRPath = (char*) InternalMalloc(pThread, g_cbszCoreCLRPath);
+
+ if (g_szCoreCLRPath == NULL)
+ {
+ ERROR("LOADGetPalLibrary: InternalMalloc failed!");
+ goto exit;
+ }
}
if (strcpy_s(g_szCoreCLRPath, g_cbszCoreCLRPath, info.dli_fname) != SAFECRT_SUCCESS)
PERFLogFileName(PathCharString * destFileString, const char *fileName, const char *suffix, int max_length)
{
const char *dir_path;
- char * destFileName = new char[max_length];
+ CPalThread* pThread = InternalGetCurrentThread();
+ char * destFileName = (char*)InternalMalloc(pThread, max_length);
dir_path = (profile_log_path == NULL) ? "." : profile_log_path;
if (fileName != NULL)
}
destFileString.Set(destFileName);
- delete [] destFileName;
+ InternalFree(pThread, destFileName);
destFileName = NULL;
}
ret = TRUE;
}
- delete [] fileName;
- fileName = NULL;
-
return ret;
}
int iFdErr = -1;
pid_t processId;
- char * lpFileName = new char[MAX_LONGPATH];
+ char * lpFileName = (char*)InternalMalloc(pThread, MAX_LONGPATH);
char **lppArgv = NULL;
UINT nArg;
int iRet;