Skip to content

Commit 3999da0

Browse files
nateboschcommit-bot@chromium.org
authored andcommitted
Fix paths when run from same directory as manifest
Towards #37610 When the `script_uri` argument to the VM has no path separators the value returned from `DirName` is identical to the input, and it is not safe to use it as a prefix for concatenating relative paths. - Compare the dirname against the script URI and use an empty prefix when they match, indicating we were unable to find a directory. - Rename `absolute_filename` to `resolved_filename` since it is not absolute in all cases. Change-Id: I62e5b06d240b55b3aa9d97d61c003adb812485e0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110137 Reviewed-by: Alexander Aprelev <[email protected]> Commit-Queue: Nate Bosch <[email protected]>
1 parent 9d78664 commit 3999da0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

runtime/bin/dfe.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,9 @@ static bool TryReadKernelListBuffer(const char* script_uri,
440440
uint8_t** kernel_ir,
441441
intptr_t* kernel_ir_size) {
442442
const char* kernel_list_dirname = DartUtils::DirName(script_uri);
443+
if (strcmp(kernel_list_dirname, script_uri) == 0) {
444+
kernel_list_dirname = "";
445+
}
443446
KernelIRNode* kernel_ir_head = nullptr;
444447
KernelIRNode* kernel_ir_tail = nullptr;
445448
// Add all kernels to the linked list
@@ -452,11 +455,11 @@ static bool TryReadKernelListBuffer(const char* script_uri,
452455
intptr_t this_kernel_size;
453456
uint8_t* this_buffer;
454457

455-
StringPointer absolute_filename(
458+
StringPointer resolved_filename(
456459
File::IsAbsolutePath(filename)
457460
? strdup(filename)
458461
: Utils::SCreate("%s%s", kernel_list_dirname, filename));
459-
if (!TryReadFile(absolute_filename.c_str(), &this_buffer,
462+
if (!TryReadFile(resolved_filename.c_str(), &this_buffer,
460463
&this_kernel_size)) {
461464
return false;
462465
}

0 commit comments

Comments
 (0)