File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -811,6 +811,9 @@ pub unsafe extern "C" fn rustsecp256k1_v0_6_1_context_create(flags: c_uint) -> *
811
811
let bytes = secp256k1_context_preallocated_size ( flags) + ALIGN_TO ;
812
812
let layout = alloc:: Layout :: from_size_align ( bytes, ALIGN_TO ) . unwrap ( ) ;
813
813
let ptr = alloc:: alloc ( layout) ;
814
+ if ptr. is_null ( ) {
815
+ alloc:: handle_alloc_error ( layout) ;
816
+ }
814
817
( ptr as * mut usize ) . write ( bytes) ;
815
818
// We must offset a whole ALIGN_TO in order to preserve the same alignment
816
819
// this means we "lose" ALIGN_TO-size_of(usize) for padding.
Original file line number Diff line number Diff line change @@ -202,6 +202,9 @@ mod alloc_only {
202
202
let size = unsafe { ffi:: secp256k1_context_preallocated_size ( C :: FLAGS ) } ;
203
203
let layout = alloc:: Layout :: from_size_align ( size, ALIGN_TO ) . unwrap ( ) ;
204
204
let ptr = unsafe { alloc:: alloc ( layout) } ;
205
+ if ptr. is_null ( ) {
206
+ alloc:: handle_alloc_error ( layout) ;
207
+ }
205
208
206
209
#[ allow( unused_mut) ] // ctx is not mutated under some feature combinations.
207
210
let mut ctx = Secp256k1 {
@@ -262,6 +265,9 @@ mod alloc_only {
262
265
let size = unsafe { ffi:: secp256k1_context_preallocated_clone_size ( self . ctx as _ ) } ;
263
266
let layout = alloc:: Layout :: from_size_align ( size, ALIGN_TO ) . unwrap ( ) ;
264
267
let ptr = unsafe { alloc:: alloc ( layout) } ;
268
+ if ptr. is_null ( ) {
269
+ alloc:: handle_alloc_error ( layout) ;
270
+ }
265
271
Secp256k1 {
266
272
ctx : unsafe {
267
273
ffi:: secp256k1_context_preallocated_clone ( self . ctx , ptr as * mut c_void )
You can’t perform that action at this time.
0 commit comments