-
Notifications
You must be signed in to change notification settings - Fork 87
Description
I noticed that the mdb_cursor_count extern function is declared as
public static extern MDBResultCode mdb_cursor_count([NativeInteger] IntPtr cursor, out int countp);I believe this is in disagreement with the C definition,
int mdb_cursor_count(MDB_cursor *mc, mdb_size_t *countp)where mdb_size_t is a typedef for size_t, which is an unsigned integer of platform-dependent size. As I understand it, it is generally pointer-sized, so 64 bits on most modern systems.
According to Microsoft, this type should be marshalled to a UIntPtr to account for this.
I'm concerned the current implementation may lead to undefined behaviour on 64-bit platforms, as the C implementation will write an 8 byte integer in a memory location only valid for 4, possibly corrupting the stack.
I took a cursory glance through the rest of the repository to see if there were any other instances of this and found that mdb_txn_id also returns a size_t that gets marshalled into an int.
I can submit a PR that fixes this issue if you agree the above looks correct; should be a very minor change.