From 1aecb656049ae6b976eee00f54ff7863d5d8e7b0 Mon Sep 17 00:00:00 2001 From: Harry Terkelsen Date: Thu, 13 Aug 2015 10:11:58 -0700 Subject: [PATCH] dart2js: remove trailing 0 byte when reading .packages BUG= R=sigmund@google.com Review URL: https://codereview.chromium.org//1290643007. --- pkg/compiler/lib/src/apiimpl.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/compiler/lib/src/apiimpl.dart b/pkg/compiler/lib/src/apiimpl.dart index 123938dbe1a4..8b78684126c8 100644 --- a/pkg/compiler/lib/src/apiimpl.dart +++ b/pkg/compiler/lib/src/apiimpl.dart @@ -379,6 +379,13 @@ class Compiler extends leg.Compiler { if (packageConfigContents is String) { packageConfigContents = UTF8.encode(packageConfigContents); } + // The input provider may put a trailing 0 byte when it reads a source + // file, which confuses the package config parser. + if (packageConfigContents.length > 0 + && packageConfigContents.last == 0) { + packageConfigContents = packageConfigContents.sublist( + 0, packageConfigContents.length - 1); + } packages = new MapPackages(pkgs.parse(packageConfigContents, packageConfig)); });