Skip to content

Commit 80ebdb5

Browse files
authored
fix: Prevent use-after-free with some geometry functions (#65)
1 parent 440578f commit 80ebdb5

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/geometry.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub extern "C" fn accesskit_affine_is_finite(affine: *const Affine) -> bool {
6060
if affine.is_null() {
6161
false
6262
} else {
63-
unsafe { Box::from_raw(affine as *mut Affine).is_finite() }
63+
unsafe { (*affine).is_finite() }
6464
}
6565
}
6666

@@ -69,7 +69,7 @@ pub extern "C" fn accesskit_affine_is_nan(affine: *const Affine) -> bool {
6969
if affine.is_null() {
7070
false
7171
} else {
72-
unsafe { Box::from_raw(affine as *mut Affine).is_nan() }
72+
unsafe { (*affine).is_nan() }
7373
}
7474
}
7575

@@ -135,7 +135,7 @@ macro_rules! rect_getter_methods {
135135
if rect.is_null() {
136136
$default_value
137137
} else {
138-
unsafe { Box::from_raw(rect as *mut Rect).$getter() }
138+
unsafe { (*rect).$getter() }
139139
}
140140
})*
141141
}
@@ -160,7 +160,7 @@ pub extern "C" fn accesskit_rect_contains(rect: *const Rect, point: Point) -> bo
160160
if rect.is_null() {
161161
false
162162
} else {
163-
unsafe { Box::from_raw(rect as *mut Rect).contains(point) }
163+
unsafe { (*rect).contains(point) }
164164
}
165165
}
166166

@@ -169,7 +169,7 @@ pub extern "C" fn accesskit_rect_union(rect: *const Rect, other: Rect) -> Rect {
169169
if rect.is_null() {
170170
Rect::ZERO
171171
} else {
172-
unsafe { Box::from_raw(rect as *mut Rect).union(other) }
172+
unsafe { (*rect).union(other) }
173173
}
174174
}
175175

@@ -178,7 +178,7 @@ pub extern "C" fn accesskit_rect_union_pt(rect: *const Rect, pt: Point) -> Rect
178178
if rect.is_null() {
179179
Rect::ZERO
180180
} else {
181-
unsafe { Box::from_raw(rect as *mut Rect).union_pt(pt) }
181+
unsafe { (*rect).union_pt(pt) }
182182
}
183183
}
184184

@@ -187,7 +187,7 @@ pub extern "C" fn accesskit_rect_intersect(rect: *const Rect, other: Rect) -> Re
187187
if rect.is_null() {
188188
Rect::ZERO
189189
} else {
190-
unsafe { Box::from_raw(rect as *mut Rect).intersect(other) }
190+
unsafe { (*rect).intersect(other) }
191191
}
192192
}
193193

0 commit comments

Comments
 (0)