aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred SUmner <jarred@jarredsumner.com> 2021-12-21 19:43:43 -0800
committerGravatar Jarred SUmner <jarred@jarredsumner.com> 2021-12-21 19:43:43 -0800
commit67b09911c17c26832d31ee56d596af4930e8d668 (patch)
tree306e700a233354bfd76bc333d1e291a1c9d8e101
parent3043bb70e14a252ccc04af5fcc1f2742be1f8620 (diff)
downloadbun-67b09911c17c26832d31ee56d596af4930e8d668.tar.gz
bun-67b09911c17c26832d31ee56d596af4930e8d668.tar.zst
bun-67b09911c17c26832d31ee56d596af4930e8d668.zip
Fix crash when TSConfigJSON has an error and multiple TSConfigJSON files were parsed \nThis was caused by reusing the filename buffer inappropriately. For unclear reasons, this only impacted Linux.
Diffstat (limited to '')
-rw-r--r--src/resolver/resolver.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig
index 4a3fffb8a..3d7404a17 100644
--- a/src/resolver/resolver.zig
+++ b/src/resolver/resolver.zig
@@ -1358,7 +1358,10 @@ pub const Resolver = struct {
false,
null,
);
- const key_path = Path.init(file);
+ // The file name needs to be persistent because it can have errors
+ // and if those errors need to print the filename
+ // then it will be undefined memory if we parse another tsconfig.json late
+ const key_path = try Path.init(file).dupeAlloc(r.allocator);
const source = logger.Source.initPathString(key_path.text, entry.contents);
const file_dir = source.path.sourceDir();
@@ -1366,6 +1369,7 @@ pub const Resolver = struct {
var result = (try TSConfigJSON.parse(r.allocator, r.log, source, &r.caches.json, r.opts.jsx.development)) orelse return null;
if (result.hasBaseURL()) {
+
// this might leak
if (!std.fs.path.isAbsolute(result.base_url)) {
const paths = [_]string{ file_dir, result.base_url };