mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
gpu_display: fix a potential memory leak in thread_message_util.
If PeekMessageW() does retrieve a message, we are responsibe for dropping it. Bug: 244489783 Test: Ran GPG Change-Id: I69250387cc93698513a47d38de52d161a0026692 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4719207 Reviewed-by: Pujun Lun <lunpujun@google.com> Reviewed-by: Vikram Auradkar <auradkar@google.com> Commit-Queue: Kaiyi Li <kaiyili@google.com>
This commit is contained in:
parent
baf1937010
commit
ca35151bc1
1 changed files with 8 additions and 2 deletions
|
@ -20,16 +20,22 @@ use winapi::um::winuser::*;
|
|||
/// It does no harm calling this function multiple times, since it won't remove any message from the
|
||||
/// queue.
|
||||
pub(crate) fn force_create_message_queue() {
|
||||
// Safe because if `message` is initialized, we will extract and drop the value.
|
||||
let mut message = mem::MaybeUninit::uninit();
|
||||
// Safe because we know the lifetime of `message`, and `PeekMessageW()` has no failure mode.
|
||||
unsafe {
|
||||
if unsafe {
|
||||
PeekMessageW(
|
||||
message.as_mut_ptr(),
|
||||
null_mut(),
|
||||
WM_USER,
|
||||
WM_USER,
|
||||
PM_NOREMOVE,
|
||||
);
|
||||
) != 0
|
||||
} {
|
||||
// Safe because `PeekMessageW()` has populated `message`.
|
||||
unsafe {
|
||||
message.assume_init_drop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue