From 5b2d9fb8d4f13e6383a5eceb2227305445416298 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sat, 28 Oct 2023 00:02:57 -0700 Subject: [PATCH] fix(ext/ffi): use anybuffer for op_ffi_buf_copy_into (#21006) Fixes https://github.com/denoland/deno/issues/21005 --- ext/ffi/repr.rs | 2 +- test_ffi/tests/test.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/ffi/repr.rs b/ext/ffi/repr.rs index 201df343e0..426affdb57 100644 --- a/ext/ffi/repr.rs +++ b/ext/ffi/repr.rs @@ -177,7 +177,7 @@ pub fn op_ffi_buf_copy_into( state: &mut OpState, src: *mut c_void, #[number] offset: isize, - #[buffer] dst: &mut [u8], + #[anybuffer] dst: &mut [u8], #[number] len: usize, ) -> Result<(), AnyError> where diff --git a/test_ffi/tests/test.js b/test_ffi/tests/test.js index 80c5663980..cb0ea71abb 100644 --- a/test_ffi/tests/test.js +++ b/test_ffi/tests/test.js @@ -327,6 +327,8 @@ const into2 = new Uint8Array(3); const into2ptr = Deno.UnsafePointer.of(into2); const into2ptrView = new Deno.UnsafePointerView(into2ptr); const into3 = new Uint8Array(3); +const into4 = new Uint16Array(3); +ptrView.copyInto(into4); ptrView.copyInto(into); console.log([...into]); ptrView.copyInto(into2, 3);