Skip to content

Commit ba5be67

Browse files
WilliamHCarterrockorager
authored andcommitted
fix: possible leak on base64 decode failure
1 parent d569f8e commit ba5be67

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/Parser.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ inline fn parseOsc(input: []const u8, paste_allocator: ?std.mem.Allocator) !Resu
314314
input[semicolon_idx + 3 .. sequence.len - 2];
315315
const decoder = std.base64.standard.Decoder;
316316
const text = try paste_allocator.?.alloc(u8, try decoder.calcSizeForSlice(payload));
317+
errdefer paste_allocator.?.free(text);
317318
try decoder.decode(text, payload);
318319
log.debug("decoded paste: {s}", .{text});
319320
return .{

0 commit comments

Comments
 (0)