aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-04 12:30:04 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-04 12:30:04 -0700
commit5467f2fc1a15f6adb11abfaf8be245e2886dea3b (patch)
tree14245d6db3d82c2bfcb20b95622b3c7a0f8e8e50
parentbff37539b9b493b101ab01e2fdfa5b71a7a3d165 (diff)
downloadbun-5467f2fc1a15f6adb11abfaf8be245e2886dea3b.tar.gz
bun-5467f2fc1a15f6adb11abfaf8be245e2886dea3b.tar.zst
bun-5467f2fc1a15f6adb11abfaf8be245e2886dea3b.zip
Fix potential crash when printing summary of node_modules.jsb without any packages in it
Former-commit-id: 928957dffcb907f188f097b13f90901f74caab86
-rw-r--r--src/node_module_bundle.zig2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/node_module_bundle.zig b/src/node_module_bundle.zig
index 274e552de..f745581fe 100644
--- a/src/node_module_bundle.zig
+++ b/src/node_module_bundle.zig
@@ -335,7 +335,7 @@ pub const NodeModuleBundle = struct {
}
pub fn printSummary(this: *const NodeModuleBundle) void {
- const last = this.bundle.packages.len - 1;
+ const last = std.math.max(this.bundle.packages.len, 1) - 1;
const indent = comptime " ";
for (this.bundle.packages) |pkg, i| {
const modules = this.bundle.modules[pkg.modules_offset .. pkg.modules_offset + pkg.modules_length];