Elaborating on the pull request title in case it helps make review easier: it looks like this caused a memory leak because stbi__convert_* was called like this:
stbi__convert_8_to_16 or stbi__convert_16_to_8 destroy the input and return a new buffer - but if allocation fails, they report an error and return 0. So, in that failure case, result is allocated (by stbi__load_*), but never freed.
This might also fix a segfault: if stbi__vertically_flip_on_load is true and stbi__convert_* fails, then the null result would be passed to stbi__vertical_flip, which tries to dereference it (if *y > 1).
Elaborating on the pull request title in case it helps make review easier: it looks like this caused a memory leak because
stbi__convert_*
was called like this:stbi__convert_8_to_16
orstbi__convert_16_to_8
destroy the input and return a new buffer - but if allocation fails, they report an error and return 0. So, in that failure case,result
is allocated (bystbi__load_*
), but never freed.This might also fix a segfault: if
stbi__vertically_flip_on_load
istrue
andstbi__convert_*
fails, then the nullresult
would be passed tostbi__vertical_flip
, which tries to dereference it (if*y > 1
).