possible memory leak in Texture.initFromFile
Closed this issue · 0 comments
ethernetsellout commented
GPA detects a memory leak here:
pub fn initFromFile(allocator: *std.mem.Allocator, file: []const u8, filter: renderkit.TextureFilter) !Texture {
const image_contents = try fs.read(allocator, file);
errdefer allocator.free(image_contents);
...
}
It seems the use of errdefer is incorrect here, it will only free the memory when there's an error. Replacing 'errdefer' with 'defer' fixes the issue and doesn't seem to cause any problems.