File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -94,9 +94,18 @@ impl<'a> ParamsRef<'a> {
94
94
/// Merges two `ParamsRef` objects into a new `Params` object.
95
95
#[ corresponds( OSSL_PARAM_merge ) ]
96
96
#[ allow( dead_code) ]
97
- pub fn merge ( & self , other : & ParamsRef < ' a > ) -> Result < Params < ' a > , ErrorStack > {
98
- cvt_p ( unsafe { ffi:: OSSL_PARAM_merge ( self . as_ptr ( ) , other. as_ptr ( ) ) } )
99
- . map ( |p| unsafe { Params :: from_ptr ( p) } )
97
+ pub fn merge ( & self , other : & ParamsRef < ' _ > ) -> Result < Params < ' a > , ErrorStack > {
98
+ // OSSL_PARAM_merge shallow copies the params
99
+ // OSSL_PARAM_free deep frees (so the params and values will be freed)
100
+ // OSSL_PARAM_dup deep copies
101
+ // Dupe both params[] so we don't end up pointing to freed memory.
102
+ cvt_p ( unsafe {
103
+ ffi:: OSSL_PARAM_merge (
104
+ ffi:: OSSL_PARAM_dup ( self . as_ptr ( ) ) ,
105
+ ffi:: OSSL_PARAM_dup ( other. as_ptr ( ) ) ,
106
+ )
107
+ } )
108
+ . map ( |p| unsafe { Params :: from_ptr ( p) } )
100
109
}
101
110
102
111
/// Locate a parameter by the given key.
You can’t perform that action at this time.
0 commit comments