mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Fix using uninitialized variable when formatting config_path. (#4129)
Close: #4128
This commit is contained in:
@@ -313,7 +313,7 @@ pub const Arguments = struct {
|
||||
defer ctx.debug.loaded_bunfig = true;
|
||||
var config_path: [:0]u8 = undefined;
|
||||
if (config_path_[0] == '/') {
|
||||
@memcpy(config_buf[0..config_path.len], config_path);
|
||||
@memcpy(config_buf[0..config_path_.len], config_path_);
|
||||
config_buf[config_path_.len] = 0;
|
||||
config_path = config_buf[0..config_path_.len :0];
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { spawnSync } from "bun";
|
||||
import { bunExe } from "harness";
|
||||
import { tmpdir } from "node:os";
|
||||
import fs from "node:fs";
|
||||
|
||||
describe("bun", () => {
|
||||
describe("NO_COLOR", () => {
|
||||
@@ -59,4 +61,22 @@ describe("bun", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("test command line arguments", () => {
|
||||
test("test --config, issue #4128", () => {
|
||||
const path = `${tmpdir()}/bunfig-${Date.now()}.toml`;
|
||||
fs.writeFileSync(path, "[debug]");
|
||||
|
||||
const p = Bun.spawnSync({
|
||||
cmd: [bunExe(), "--config", path],
|
||||
env: {},
|
||||
stderr: "inherit",
|
||||
});
|
||||
try {
|
||||
expect(p.exitCode).toBe(0);
|
||||
} finally {
|
||||
fs.unlinkSync(path);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user