@@ -128,17 +128,14 @@ vectors! {
128
128
cfg_if ! {
129
129
if #[ cfg( feature = "enable-interning" ) ] {
130
130
#[ inline]
131
- fn get_cached_str( x: & str ) -> Option <WasmSlice > {
132
- // This is safe because the JsValue is immediately looked up in the heap and
133
- // then returned, so use-after-free cannot occur.
134
- //
131
+ fn unsafe_get_cached_str( x: & str ) -> Option <WasmSlice > {
135
132
// This uses 0 for the ptr as an indication that it is a JsValue and not a str.
136
133
crate :: cache:: intern:: unsafe_get_str( x) . map( |x| WasmSlice { ptr: 0 , len: x } )
137
134
}
138
135
139
136
} else {
140
137
#[ inline]
141
- fn get_cached_str ( _x: & str ) -> Option <WasmSlice > {
138
+ fn unsafe_get_cached_str ( _x: & str ) -> Option <WasmSlice > {
142
139
None
143
140
}
144
141
}
@@ -175,7 +172,9 @@ if_std! {
175
172
176
173
#[ inline]
177
174
fn into_abi( self ) -> Self :: Abi {
178
- get_cached_str( & self ) . unwrap_or_else( || self . into_bytes( ) . into_abi( ) )
175
+ // This is safe because the JsValue is immediately looked up in the heap and
176
+ // then returned, so use-after-free cannot occur.
177
+ unsafe_get_cached_str( & self ) . unwrap_or_else( || self . into_bytes( ) . into_abi( ) )
179
178
}
180
179
}
181
180
@@ -202,7 +201,9 @@ impl<'a> IntoWasmAbi for &'a str {
202
201
203
202
#[ inline]
204
203
fn into_abi ( self ) -> Self :: Abi {
205
- get_cached_str ( self ) . unwrap_or_else ( || self . as_bytes ( ) . into_abi ( ) )
204
+ // This is safe because the JsValue is immediately looked up in the heap and
205
+ // then returned, so use-after-free cannot occur.
206
+ unsafe_get_cached_str ( self ) . unwrap_or_else ( || self . as_bytes ( ) . into_abi ( ) )
206
207
}
207
208
}
208
209
0 commit comments