Skip to content

Commit

Permalink
Fix crash with write_to_file/buffer with Lua 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed Mar 28, 2024
1 parent 13ff3f7 commit 13c585f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/vips/Image_methods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,23 @@ end
-- writers

function Image_method:write_to_file(vips_filename, ...)
collectgarbage("stop")
local filename = to_string_copy(vips_lib.vips_filename_get_filename(vips_filename))
local options = to_string_copy(vips_lib.vips_filename_get_options(vips_filename))
local name = vips_lib.vips_foreign_find_save(filename)
collectgarbage("restart")
if name == ffi.NULL then
error(verror.get())
end

return voperation.call(ffi.string(name), options,
self, filename, unpack { ... })
end

function Image_method:write_to_buffer(format_string, ...)
collectgarbage("stop")
local options = to_string_copy(vips_lib.vips_filename_get_options(format_string))
local name = vips_lib.vips_foreign_find_save_buffer(format_string)
collectgarbage("restart")
if name == ffi.NULL then
error(verror.get())
end
Expand Down

0 comments on commit 13c585f

Please sign in to comment.