| ... | @@ -736,7 +736,8 @@ fn fmtPathFile( | ... | @@ -736,7 +736,8 @@ fn fmtPathFile( |
| 736 | sub_path: []const u8, | 736 | sub_path: []const u8, |
| 737 | ) FmtError!void { | 737 | ) FmtError!void { |
| 738 | const source_file = try dir.openFile(sub_path, .{}); | 738 | const source_file = try dir.openFile(sub_path, .{}); |
| 739 | defer source_file.close(); | 739 | var file_closed = false; |
| | 740 | errdefer if (!file_closed) source_file.close(); |
| 740 | | 741 | |
| 741 | const stat = try source_file.stat(); | 742 | const stat = try source_file.stat(); |
| 742 | | 743 | |
| ... | @@ -748,6 +749,8 @@ fn fmtPathFile( | ... | @@ -748,6 +749,8 @@ fn fmtPathFile( |
| 748 | error.ConnectionTimedOut => unreachable, | 749 | error.ConnectionTimedOut => unreachable, |
| 749 | else => |e| return e, | 750 | else => |e| return e, |
| 750 | }; | 751 | }; |
| | 752 | source_file.close(); |
| | 753 | file_closed = true; |
| 751 | defer fmt.gpa.free(source_code); | 754 | defer fmt.gpa.free(source_code); |
| 752 | | 755 | |
| 753 | // Add to set after no longer possible to get error.IsDir. | 756 | // Add to set after no longer possible to get error.IsDir. |