File tree 1 file changed +14
-5
lines changed
1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -809,13 +809,15 @@ mod tests {
809
809
810
810
#[ test]
811
811
fn test_raw_ctx ( ) {
812
+ use std:: mem:: ManuallyDrop ;
813
+
812
814
let ctx_full = Secp256k1 :: new ( ) ;
813
815
let ctx_sign = Secp256k1 :: signing_only ( ) ;
814
816
let ctx_vrfy = Secp256k1 :: verification_only ( ) ;
815
817
816
- let full = unsafe { Secp256k1 :: from_raw_all ( ctx_full. ctx ) } ;
817
- let sign = unsafe { Secp256k1 :: from_raw_signining_only ( ctx_sign. ctx ) } ;
818
- let vrfy = unsafe { Secp256k1 :: from_raw_verification_only ( ctx_vrfy. ctx ) } ;
818
+ let mut full = unsafe { Secp256k1 :: from_raw_all ( ctx_full. ctx ) } ;
819
+ let mut sign = unsafe { Secp256k1 :: from_raw_signining_only ( ctx_sign. ctx ) } ;
820
+ let mut vrfy = unsafe { Secp256k1 :: from_raw_verification_only ( ctx_vrfy. ctx ) } ;
819
821
820
822
let ( sk, pk) = full. generate_keypair ( & mut thread_rng ( ) ) ;
821
823
let msg = Message :: from_slice ( & [ 2u8 ; 32 ] ) . unwrap ( ) ;
@@ -827,8 +829,15 @@ mod tests {
827
829
assert ! ( vrfy. verify( & msg, & sig, & pk) . is_ok( ) ) ;
828
830
assert ! ( full. verify( & msg, & sig, & pk) . is_ok( ) ) ;
829
831
830
- drop ( full) ; drop ( sign) ; drop ( vrfy) ;
831
- drop ( ctx_full) ; drop ( ctx_sign) ; drop ( ctx_vrfy) ;
832
+ unsafe {
833
+ ManuallyDrop :: drop ( & mut full) ;
834
+ ManuallyDrop :: drop ( & mut sign) ;
835
+ ManuallyDrop :: drop ( & mut vrfy) ;
836
+
837
+ }
838
+ drop ( ctx_full) ;
839
+ drop ( ctx_sign) ;
840
+ drop ( ctx_vrfy) ;
832
841
}
833
842
834
843
#[ test]
You can’t perform that action at this time.
0 commit comments