Skip to content

Commit a13b4ea

Browse files
committed
Bug 1836883. Avoid passing ref function arguments to Rc::from_raw. r=eemeli
It is unfortunately undefined behavior and leads to problems with LLVM 16. Differential Revision: https://phabricator.services.mozilla.com/D180061
1 parent 473dfca commit a13b4ea

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

intl/l10n/rust/fluent-ffi/src/bundle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ pub extern "C" fn fluent_bundle_format_pattern(
294294
#[no_mangle]
295295
pub unsafe extern "C" fn fluent_bundle_add_resource(
296296
bundle: &mut FluentBundleRc,
297-
r: &FluentResource,
297+
r: *const FluentResource,
298298
allow_overrides: bool,
299299
ret_errors: &mut ThinVec<nsCString>,
300300
) {

intl/l10n/rust/fluent-ffi/src/resource.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub extern "C" fn fluent_resource_new(
2828
}
2929

3030
#[no_mangle]
31-
pub unsafe extern "C" fn fluent_resource_addref(res: &FluentResource) {
31+
pub unsafe extern "C" fn fluent_resource_addref(res: *const FluentResource) {
3232
let raw = ManuallyDrop::new(Rc::from_raw(res));
3333
mem::forget(Rc::clone(&raw));
3434
}

intl/l10n/rust/l10nregistry-ffi/src/registry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ pub unsafe extern "C" fn l10nregistry_register_parent_process_sources(
255255
}
256256

257257
#[no_mangle]
258-
pub unsafe extern "C" fn l10nregistry_addref(reg: &GeckoL10nRegistry) {
258+
pub unsafe extern "C" fn l10nregistry_addref(reg: *const GeckoL10nRegistry) {
259259
let raw = Rc::from_raw(reg);
260260
mem::forget(Rc::clone(&raw));
261261
mem::forget(raw);
262262
}
263263

264264
#[no_mangle]
265-
pub unsafe extern "C" fn l10nregistry_release(reg: &GeckoL10nRegistry) {
265+
pub unsafe extern "C" fn l10nregistry_release(reg: *const GeckoL10nRegistry) {
266266
let _ = Rc::from_raw(reg);
267267
}
268268

intl/l10n/rust/l10nregistry-ffi/src/source.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub extern "C" fn l10nfilesource_new_mock(
199199
}
200200

201201
#[no_mangle]
202-
pub unsafe extern "C" fn l10nfilesource_addref(source: &FileSource) {
202+
pub unsafe extern "C" fn l10nfilesource_addref(source: *const FileSource) {
203203
let raw = Rc::from_raw(source);
204204
mem::forget(Rc::clone(&raw));
205205
mem::forget(raw);

0 commit comments

Comments
 (0)