File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
core/engine/src/value/inner Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -577,6 +577,13 @@ impl NanBoxedValue {
577577 bits:: is_integer32 ( self . 0 )
578578 }
579579
580+ /// Returns true if a value is a pointer type.
581+ #[ must_use]
582+ #[ inline( always) ]
583+ pub ( crate ) const fn is_pointer ( & self ) -> bool {
584+ bits:: is_pointer ( self . 0 )
585+ }
586+
580587 /// Returns true if a value is a `[JsBigInt]`. A `NaN` will not match here.
581588 #[ must_use]
582589 #[ inline( always) ]
@@ -717,14 +724,16 @@ impl Drop for NanBoxedValue {
717724 let maybe_ptr = self . 0 & bits:: POINTER_MASK ;
718725
719726 // Drop the pointer if it is a pointer.
720- if self . is_object ( ) {
721- drop ( unsafe { Box :: from_raw ( maybe_ptr as * mut JsObject ) } ) ;
722- } else if self . is_bigint ( ) {
723- drop ( unsafe { Box :: from_raw ( maybe_ptr as * mut JsBigInt ) } ) ;
724- } else if self . is_symbol ( ) {
725- drop ( unsafe { Box :: from_raw ( maybe_ptr as * mut JsSymbol ) } ) ;
726- } else if self . is_string ( ) {
727- drop ( unsafe { Box :: from_raw ( maybe_ptr as * mut JsString ) } ) ;
727+ if self . is_pointer ( ) {
728+ if self . is_string ( ) {
729+ drop ( unsafe { Box :: from_raw ( maybe_ptr as * mut JsString ) } ) ;
730+ } else if self . is_object ( ) {
731+ drop ( unsafe { Box :: from_raw ( maybe_ptr as * mut JsObject ) } ) ;
732+ } else if self . is_bigint ( ) {
733+ drop ( unsafe { Box :: from_raw ( maybe_ptr as * mut JsBigInt ) } ) ;
734+ } else if self . is_symbol ( ) {
735+ drop ( unsafe { Box :: from_raw ( maybe_ptr as * mut JsSymbol ) } ) ;
736+ }
728737 }
729738 }
730739}
You can’t perform that action at this time.
0 commit comments