Closed Shadow53 closed 1 year ago
The immediate solution I see is to swap ret.inner
with a nullptr
and return the swapped-out value, but I am wondering if you would be open to a PR with a larger refactor that wraps pointers in Rc
/Arc
internally to avoid this sort of problem in the future.
Sure! Pull requests are welcome.
Worked at this for a bit, only to realize that fz_keep_*
and fz_drop_*
increase/decrease existing reference counts, so adding Rust-level reference counting would be unnecessary complexity on top of that.
About to open a PR that just fixes this issue instead of refactoring everything.
When I process images using
set_image_filter
, I get a segmentation fault.I was able to trace the issue to this line, where
ret.inner
is copied (since pointers areCopy
) and returned, andret
is dropped, which frees the memory using mupdf'sfz_drop_image
.