Skip to content

Commit

Permalink
Fix RegKey::close_() to work properly with windows-sys
Browse files Browse the repository at this point in the history
  • Loading branch information
Philosobyte authored and gentoo90 committed Apr 3, 2023
1 parent 0944a8a commit 7a6a4f9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/reg_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,9 @@ impl RegKey {

fn close_(&mut self) -> io::Result<()> {
// don't try to close predefined keys
if self.hkey >= enums::HKEY_CLASSES_ROOT {
// The root hkey overflows with windows-sys, where HKEY is an alias for isize.
// Cast to u32 to keep comparisons intact.
if self.hkey as usize >= enums::HKEY_CLASSES_ROOT as usize {
return Ok(());
};
match unsafe { Registry::RegCloseKey(self.hkey) } {
Expand Down

0 comments on commit 7a6a4f9

Please sign in to comment.