diff --git a/lib/std/zig/Parse.zig b/lib/std/zig/Parse.zig index 33b2cf21b54ff3593e4a849562ac19a0e6ad042f..0e4fe3109f3648d484567a0c6ecb2dea5a902d3a 100644 --- a/lib/std/zig/Parse.zig +++ b/lib/std/zig/Parse.zig @@ -1249,13 +1249,17 @@ fn parseLabeledStatement(p: *Parse) !?Node.Index { const label_token = opt_label_token orelse return null; const after_colon = p.tok_i; - if (try p.parseTypeExpr()) |_| { - const a = try p.parseByteAlign(); - const b = try p.parseAddrSpace(); - const c = try p.parseLinkSection(); - const d = if (p.eatToken(.equal) == null) null else try p.expectExpr(); - if (a != null or b != null or c != null or d != null) { - return p.failMsg(.{ .tag = .expected_var_const, .token = label_token }); + // Don't bother trying to give a better error message if recovery is disabled. + // This avoids a possible stack overflow in e.g. parseTypeExpr() when fuzzing. + if (p.recover) { + if (try p.parseTypeExpr()) |_| { + const a = try p.parseByteAlign(); + const b = try p.parseAddrSpace(); + const c = try p.parseLinkSection(); + const d = if (p.eatToken(.equal) == null) null else try p.expectExpr(); + if (a != null or b != null or c != null or d != null) { + return p.failMsg(.{ .tag = .expected_var_const, .token = label_token }); + } } } return p.failMsg(.{ .tag = .expected_labelable, .token = after_colon });