Skip to content

Commit 7ac7983

Browse files
a-sivaCommit Queue
authored andcommitted
Call File::GetCanonicalPath in Platform::ResolveExecutablePathInto() to make
it uniform with Platform::ResolveExecutablePath() TEST=ci Change-Id: Ib9e2f0c8ce2dc0d10cb67ceb3c3166f37201391f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434040 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Siva Annamalai <[email protected]>
1 parent beca727 commit 7ac7983

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

runtime/bin/platform_win.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,16 +386,20 @@ intptr_t Platform::ResolveExecutablePathInto(char* result, size_t result_size) {
386386
// Ensure no last error before calling GetModuleFileNameW.
387387
SetLastError(ERROR_SUCCESS);
388388
const int kTmpBufferSize = 32768;
389-
wchar_t tmp_buffer[kTmpBufferSize];
389+
wchar_t tmp_buffer_1[kTmpBufferSize];
390+
char tmp_buffer_2[kTmpBufferSize];
390391
// Get the required length of the buffer.
391-
GetModuleFileNameW(nullptr, tmp_buffer, kTmpBufferSize);
392+
GetModuleFileNameW(nullptr, tmp_buffer_1, kTmpBufferSize);
392393
if (GetLastError() != ERROR_SUCCESS) {
393394
return -1;
394395
}
395-
WideToUtf8Scope wide_to_utf8_scope(tmp_buffer);
396-
if (wide_to_utf8_scope.length() <= result_size) {
397-
strncpy(result, wide_to_utf8_scope.utf8(), result_size);
398-
return wide_to_utf8_scope.length();
396+
WideToUtf8Scope wide_to_utf8_scope(tmp_buffer_1);
397+
if (wide_to_utf8_scope.length() <= kTmpBufferSize) {
398+
strncpy(tmp_buffer_2, wide_to_utf8_scope.utf8(), kTmpBufferSize);
399+
if (!File::GetCanonicalPath(nullptr, tmp_buffer_2, result, result_size)) {
400+
return -1;
401+
}
402+
return strlen(result);
399403
}
400404
return -1;
401405
}

0 commit comments

Comments
 (0)