Skip to content

Commit 021059a

Browse files
committed
Fix crash with write_to_file/buffer with Lua 5.4
1 parent 13ff3f7 commit 021059a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/vips/Image_methods.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,23 @@ end
370370
-- writers
371371

372372
function Image_method:write_to_file(vips_filename, ...)
373+
collectgarbage("stop")
373374
local filename = to_string_copy(vips_lib.vips_filename_get_filename(vips_filename))
374375
local options = to_string_copy(vips_lib.vips_filename_get_options(vips_filename))
375376
local name = vips_lib.vips_foreign_find_save(filename)
377+
collectgarbage("restart")
376378
if name == ffi.NULL then
377379
error(verror.get())
378380
end
379-
380381
return voperation.call(ffi.string(name), options,
381382
self, filename, unpack { ... })
382383
end
383384

384385
function Image_method:write_to_buffer(format_string, ...)
386+
collectgarbage("stop")
385387
local options = to_string_copy(vips_lib.vips_filename_get_options(format_string))
386388
local name = vips_lib.vips_foreign_find_save_buffer(format_string)
389+
collectgarbage("restart")
387390
if name == ffi.NULL then
388391
error(verror.get())
389392
end

0 commit comments

Comments
 (0)