File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 27
27
extern crate libmimalloc_sys as ffi;
28
28
29
29
use core:: alloc:: { GlobalAlloc , Layout } ;
30
+ use core:: ptr;
30
31
use libc:: c_void;
31
32
use ffi:: * ;
32
33
@@ -68,6 +69,13 @@ unsafe impl GlobalAlloc for MiMalloc {
68
69
if layout. align ( ) <= MIN_ALIGN && layout. align ( ) <= layout. size ( ) {
69
70
mi_malloc ( layout. size ( ) ) as * mut u8
70
71
} else {
72
+ #[ cfg( target_os = "macos" ) ]
73
+ {
74
+ if layout. align ( ) > ( 1 << 31 ) {
75
+ return ptr:: null_mut ( )
76
+ }
77
+ }
78
+
71
79
mi_malloc_aligned ( layout. size ( ) , layout. align ( ) ) as * mut u8
72
80
}
73
81
}
@@ -77,6 +85,13 @@ unsafe impl GlobalAlloc for MiMalloc {
77
85
if layout. align ( ) <= MIN_ALIGN && layout. align ( ) <= layout. size ( ) {
78
86
mi_zalloc ( layout. size ( ) ) as * mut u8
79
87
} else {
88
+ #[ cfg( target_os = "macos" ) ]
89
+ {
90
+ if layout. align ( ) > ( 1 << 31 ) {
91
+ return ptr:: null_mut ( )
92
+ }
93
+ }
94
+
80
95
mi_zalloc_aligned ( layout. size ( ) , layout. align ( ) ) as * mut u8
81
96
}
82
97
}
You can’t perform that action at this time.
0 commit comments