| Index: runtime/bin/builtin.cc
|
| diff --git a/runtime/bin/builtin.cc b/runtime/bin/builtin.cc
|
| index c52f314aa76ed322608017dc0f3d9eb276371f48..021140bea78dc4540595dc91d6d222f04eeeada8 100644
|
| --- a/runtime/bin/builtin.cc
|
| +++ b/runtime/bin/builtin.cc
|
| @@ -27,8 +27,14 @@ Dart_Port Builtin::load_port_ = ILLEGAL_PORT;
|
| static void LoadPatchFiles(Dart_Handle library,
|
| const char* patch_uri,
|
| const char** patch_files) {
|
| - for (intptr_t j = 0; patch_files[j] != NULL; j += 2) {
|
| + for (intptr_t j = 0; patch_files[j] != NULL; j += 3) {
|
| Dart_Handle patch_src = DartUtils::ReadStringFromFile(patch_files[j + 1]);
|
| + if (!Dart_IsString(patch_src)) {
|
| + // In case reading the file caused an error, use the sources directly.
|
| + const char* source = patch_files[j + 2];
|
| + patch_src = Dart_NewStringFromUTF8(
|
| + reinterpret_cast<const uint8_t*>(source), strlen(source));
|
| + }
|
|
|
| // Prepend the patch library URI to form a unique script URI for the patch.
|
| intptr_t len = snprintf(NULL, 0, "%s/%s", patch_uri, patch_files[j]);
|
| @@ -69,17 +75,20 @@ Dart_Handle Builtin::GetSource(const char** source_paths, const char* uri) {
|
| if (source_paths == NULL) {
|
| return Dart_Null(); // No path mapping information exists for library.
|
| }
|
| - const char* source_path = NULL;
|
| - for (intptr_t i = 0; source_paths[i] != NULL; i += 2) {
|
| + for (intptr_t i = 0; source_paths[i] != NULL; i += 3) {
|
| if (!strcmp(uri, source_paths[i])) {
|
| - source_path = source_paths[i + 1];
|
| - break;
|
| + const char* source_path = source_paths[i + 1];
|
| + Dart_Handle src = DartUtils::ReadStringFromFile(source_path);
|
| + if (!Dart_IsString(src)) {
|
| + // In case reading the file caused an error, use the sources directly.
|
| + const char* source = source_paths[i + 2];
|
| + src = Dart_NewStringFromUTF8(
|
| + reinterpret_cast<const uint8_t*>(source), strlen(source));
|
| + }
|
| + return src;
|
| }
|
| }
|
| - if (source_path == NULL) {
|
| - return Dart_Null(); // Uri does not exist in path mapping information.
|
| - }
|
| - return DartUtils::ReadStringFromFile(source_path);
|
| + return Dart_Null(); // Uri does not exist in path mapping information.
|
| }
|
|
|
|
|
|
|