debug: fix memory leak when an error occurs opening a pdb file

This commit is contained in:
kcbanner 2023-05-27 17:33:13 -04:00
parent 865d4d2d8c
commit dd2035735f

View file

@ -881,6 +881,7 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_bytes: []const u8) !ModuleDe
// Only used by pdb path // Only used by pdb path
di.coff_section_headers = try coff_obj.getSectionHeadersAlloc(allocator); di.coff_section_headers = try coff_obj.getSectionHeadersAlloc(allocator);
errdefer allocator.free(di.coff_section_headers);
var path_buf: [windows.MAX_PATH]u8 = undefined; var path_buf: [windows.MAX_PATH]u8 = undefined;
const len = try coff_obj.getPdbPath(path_buf[0..]); const len = try coff_obj.getPdbPath(path_buf[0..]);