diff options
| author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-03-31 21:16:25 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-31 17:46:25 +0200 |
| commit | feab94ff512987a9a7e01f41d7a1788712b4247c (patch) | |
| tree | fd968bed8e1b1a0f7d3f76182f41a213b7f2b944 /ops/optimizer_tests/cow_str.out | |
| parent | b9a379093264da47368ea9665f685016fe35bfca (diff) | |
fix(ops): fallback when FastApiOneByteString is not utf8 (#18518)
Fixes https://github.com/denoland/deno/issues/18255
Diffstat (limited to 'ops/optimizer_tests/cow_str.out')
| -rw-r--r-- | ops/optimizer_tests/cow_str.out | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ops/optimizer_tests/cow_str.out b/ops/optimizer_tests/cow_str.out index 8ee82078b..dc909da81 100644 --- a/ops/optimizer_tests/cow_str.out +++ b/ops/optimizer_tests/cow_str.out @@ -31,7 +31,7 @@ impl op_cow_str { use deno_core::v8::fast_api::CType; Some( deno_core::v8::fast_api::FastFunction::new( - &[V8Value, SeqOneByteString], + &[V8Value, SeqOneByteString, CallbackOptions], CType::Void, op_cow_str_fast_fn as *const ::std::ffi::c_void, ), @@ -77,10 +77,19 @@ impl op_cow_str { fn op_cow_str_fast_fn<'scope>( _: deno_core::v8::Local<deno_core::v8::Object>, c: *const deno_core::v8::fast_api::FastApiOneByteString, + fast_api_callback_options: *mut deno_core::v8::fast_api::FastApiCallbackOptions, ) -> () { use deno_core::v8; use deno_core::_ops; - let c = ::std::borrow::Cow::Borrowed(unsafe { &*c }.as_str()); + let c = ::std::borrow::Cow::Borrowed( + match ::std::str::from_utf8(unsafe { &*c }.as_bytes()) { + Ok(v) => v, + Err(_) => { + unsafe { &mut *fast_api_callback_options }.fallback = true; + return Default::default(); + } + }, + ); let result = op_cow_str::call(c); result } |
