Skip to content

Commit 07a606f

Browse files
committed
Fix memory corruption with FFI backend
1 parent cb7a484 commit 07a606f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/fiddle/ffi_backend.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def self.from_native(value, ctx)
239239

240240
def self.to_ptr(value)
241241
if value.is_a?(String)
242-
cptr = Pointer.malloc(value.bytesize)
242+
cptr = Pointer.malloc(value.bytesize + 1)
243243
cptr.ffi_ptr.put_string(0, value)
244244
cptr
245245

0 commit comments

Comments
 (0)