Bug 8479 - WinSerialStream calls Marshal.StructureToPtr with incorrect parameter
Summary: WinSerialStream calls Marshal.StructureToPtr with incorrect parameter
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-11-17 20:33 UTC by Alex
Modified: 2012-11-21 10:02 UTC (History)
1 user (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Alex 2012-11-17 20:33:26 UTC
Constructor of WinSerialStream class calls twice Marshal.StructureToPtr method on lines 114 and 120 of WinSerialStream.cs. The third parameter of StructureToPtr - fDeleteOld, is specified as "true" but it must be "false" because StructureToPtr operates with newly allocated memory and there is nothing to be deleted there. In this case StructureToPtr does not crash just because NativeOverlapped structure does not contain fields of reference type.
Comment 1 Alex 2012-11-21 10:02:18 UTC
To be more precise - the following lines in WinSerialStreamcs

Marshal.StructureToPtr (wo, write_overlapped, true);
Marshal.StructureToPtr (ro, read_overlapped, true);

should become

Marshal.StructureToPtr (wo, write_overlapped, false);
Marshal.StructureToPtr (ro, read_overlapped, false);

Note You need to log in before you can comment on or make changes to this bug.