| ... | @@ -353,9 +353,14 @@ fn Parser(comptime ReaderType: type) type { | ... | @@ -353,9 +353,14 @@ fn Parser(comptime ReaderType: type) type { |
| 353 | var debug_names = std.ArrayList(u8).init(gpa); | 353 | var debug_names = std.ArrayList(u8).init(gpa); |
| 354 | | 354 | |
| 355 | errdefer { | 355 | errdefer { |
| 356 | while (relocatable_data.popOrNull()) |rel_data| { | 356 | // only free the inner contents of relocatable_data if we didn't |
| 357 | gpa.free(rel_data.data[0..rel_data.size]); | 357 | // assign it to the object yet. |
| 358 | } else relocatable_data.deinit(); | 358 | if (parser.object.relocatable_data.len == 0) { |
| | 359 | for (relocatable_data.items) |rel_data| { |
| | 360 | gpa.free(rel_data.data[0..rel_data.size]); |
| | 361 | } |
| | 362 | relocatable_data.deinit(); |
| | 363 | } |
| 359 | gpa.free(debug_names.items); | 364 | gpa.free(debug_names.items); |
| 360 | debug_names.deinit(); | 365 | debug_names.deinit(); |
| 361 | } | 366 | } |