Skip to content

Commit

Permalink
Merge pull request #1373 from n1000/show_message_box_use_after_free
Browse files Browse the repository at this point in the history
Fix use after free in show_message_box
  • Loading branch information
Cobrand authored Feb 9, 2024
2 parents c971a98 + 65b8914 commit 79f8ad0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/sdl2/messagebox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,20 @@ where
})
.collect();
let result = unsafe {
let scheme = scheme.map(|scheme| sys::SDL_MessageBoxColorScheme {
colors: scheme.into(),
});
let msg_box_data = sys::SDL_MessageBoxData {
flags: flags.bits(),
window: window.map_or(ptr::null_mut(), |win| win.raw()),
title: title.as_ptr() as *const c_char,
message: message.as_ptr() as *const c_char,
numbuttons: raw_buttons.len() as c_int,
buttons: raw_buttons.as_ptr(),
colorScheme: if let Some(scheme) = scheme {
&sys::SDL_MessageBoxColorScheme {
colors: From::from(scheme),
} as *const _
} else {
ptr::null()
},
colorScheme: scheme
.as_ref()
.map(|p| p as *const _)
.unwrap_or(ptr::null()),
};
sys::SDL_ShowMessageBox(&msg_box_data as *const _, &mut button_id as &mut _)
} == 0;
Expand Down

0 comments on commit 79f8ad0

Please sign in to comment.