elast0ny / shared_memory

A Rust wrapper around native shared memory for Linux and Windows
382 stars 51 forks source link

other bugs in windows.rs #52

Closed ExpHP closed 4 years ago

ExpHP commented 4 years ago

https://github.com/elast0ny/shared_memory-rs/blob/749f11db3324afc41d67a8229bbbd059856494a6/src/windows.rs#L63

This is missing a right-shift.

ExpHP commented 4 years ago

One other final thing:

https://github.com/elast0ny/shared_memory-rs/blob/749f11db3324afc41d67a8229bbbd059856494a6/src/windows.rs#L88-L90

I noticed that this handle is explicitly cleaned up on failure, while nothing else is. That's when it occurred to me that the reason why new_map is initialized at the beginning with dummy data (and why the Drop impl checks for null pointers) is that, in these functions, new_map's drop impl is being used to clean up everything on failure.

However, that means that, in this particular exit branch, I believe CloseHandle gets called on new_map.map_handle twice?