From 5467f2fc1a15f6adb11abfaf8be245e2886dea3b Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 4 Aug 2021 12:30:04 -0700 Subject: [PATCH] Fix potential crash when printing summary of node_modules.jsb without any packages in it Former-commit-id: 928957dffcb907f188f097b13f90901f74caab86 --- src/node_module_bundle.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_module_bundle.zig b/src/node_module_bundle.zig index 274e552de1..f745581fe2 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];