Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions crates/vm/src/stdlib/_codecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,19 +791,18 @@ mod _codecs_windows {

// Convert code point to UTF-16
let mut wchars = [0u16; 2];
let wchar_len;
let is_surrogate = (0xD800..=0xDFFF).contains(&ch);

if is_surrogate {
wchar_len = 0; // Can't encode surrogates normally
let wchar_len = if is_surrogate {
0 // Can't encode surrogates normally
} else if ch < 0x10000 {
wchars[0] = ch as u16;
wchar_len = 1;
1
} else {
wchars[0] = ((ch - 0x10000) >> 10) as u16 + 0xD800;
wchars[1] = ((ch - 0x10000) & 0x3FF) as u16 + 0xDC00;
wchar_len = 2;
}
2
};

if !is_surrogate {
let mut buf = [0u8; 8];
Expand Down
16 changes: 16 additions & 0 deletions crates/vm/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,10 @@ impl VirtualMachine {

let initial_ptr = self.take_pending_tailcall();
// Drain the refs that keep the initial callee's raw pointers alive.
#[allow(
clippy::drain_collect,
reason = "`pending_tailcall_refs`'s allocation is intentionally reused"
)]
let initial_refs = unsafe { &mut *self.pending_tailcall_refs.get() }
.drain(..)
.collect();
Expand Down Expand Up @@ -1498,6 +1502,10 @@ impl VirtualMachine {
let result = crate::frame::run_iframe(callee, self);
match result {
Ok(ExecutionResult::TailCall) => {
#[allow(
clippy::drain_collect,
reason = "`pending_tailcall_refs`'s allocation is intentionally reused"
)]
let refs = unsafe { &mut *self.pending_tailcall_refs.get() }
.drain(..)
.collect();
Expand Down Expand Up @@ -1548,6 +1556,10 @@ impl VirtualMachine {
let result = crate::frame::run_iframe(caller_iframe, self);
match result {
Ok(ExecutionResult::TailCall) => {
#[allow(
clippy::drain_collect,
reason = "`pending_tailcall_refs`'s allocation is intentionally reused"
)]
let refs = unsafe { &mut *self.pending_tailcall_refs.get() }
.drain(..)
.collect();
Expand Down Expand Up @@ -1609,6 +1621,10 @@ impl VirtualMachine {
let result = crate::frame::run_iframe(caller_iframe, self);
match result {
Ok(ExecutionResult::TailCall) => {
#[allow(
clippy::drain_collect,
reason = "`pending_tailcall_refs`'s allocation is intentionally reused"
)]
let refs = unsafe { &mut *self.pending_tailcall_refs.get() }
.drain(..)
.collect();
Expand Down
Loading