mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
PNG: Fix leak if you don't ask for metadata.
This commit is contained in:
@@ -34,10 +34,8 @@ destroy :: proc(img: ^Image) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bytes.buffer_destroy(&img.pixels);
|
bytes.buffer_destroy(&img.pixels);
|
||||||
if img.metadata_ptr != nil && img.metadata_type == Info {
|
// Clean up Info.
|
||||||
// Clean up Info.
|
free(img.metadata_ptr);
|
||||||
free(img.metadata_ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We don't need to do anything for the individual chunks.
|
We don't need to do anything for the individual chunks.
|
||||||
|
|||||||
@@ -402,6 +402,8 @@ load_from_stream :: proc(stream: io.Stream, options := Options{}, allocator := c
|
|||||||
}
|
}
|
||||||
|
|
||||||
info := new(Info, context.allocator);
|
info := new(Info, context.allocator);
|
||||||
|
img.metadata_ptr = info;
|
||||||
|
img.metadata_type = typeid_of(Info);
|
||||||
|
|
||||||
ctx := &compress.Context{
|
ctx := &compress.Context{
|
||||||
input = stream,
|
input = stream,
|
||||||
@@ -663,10 +665,6 @@ load_from_stream :: proc(stream: io.Stream, options := Options{}, allocator := c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if .return_header in options || .return_metadata in options {
|
|
||||||
img.metadata_ptr = info;
|
|
||||||
img.metadata_type = typeid_of(Info);
|
|
||||||
}
|
|
||||||
if .do_not_decompress_image in options {
|
if .do_not_decompress_image in options {
|
||||||
img.channels = final_image_channels;
|
img.channels = final_image_channels;
|
||||||
return img, nil;
|
return img, nil;
|
||||||
|
|||||||
Reference in New Issue
Block a user