Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate UB around move semantics in display logic #75

Merged
merged 1 commit into from
Mar 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lvgl/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl<'a, const N: usize> DisplayDriver<N> {
.ok_or(DisplayError::FailedToRegister)?,
) as *mut _;

disp_drv.user_data = Box::into_raw(Box::new(display_update_callback)) as *mut _;
disp_drv.user_data = Box::new(display_update_callback).into_raw() as *mut _;

// Sets trampoline pointer to the function implementation that uses the `F` type for a
// refresh buffer of size N specifically.
Expand Down Expand Up @@ -350,7 +350,8 @@ unsafe extern "C" fn disp_flush_trampoline<'a, F, const N: usize>(
};
callback(&update);
}

// Not doing this causes a segfault in rust >= 1.69.0
*disp_drv = display_driver;
// Indicate to LVGL that we are ready with the flushing
lvgl_sys::lv_disp_flush_ready(disp_drv);
}
Expand Down