SerReadTimeout: invalid passing of parameter in Windows implementation
Original Reporter info from Mantis: Martok @martok
-
Reporter name:
Original Reporter info from Mantis: Martok @martok
- Reporter name:
Description:
In rtl-extra's unit serial, the version of SerReadTimeout with a count parameter has the signature
function SerReadTimeout(Handle: TSerialHandle; var Buffer: array of byte; count, mSec: LongInt): LongInt;
In packages/rtl-extra/src/win/serial.pp:466, the buffer is passed incorrectly as
ReadFile(Handle, Buffer, count, BytesRead, nil)
This overwrites the address of the dynarray (and some memory after that pointer), not the allocated memory. This should be either Buffer[0] -- or change the interface to not use a dynarray and instead use an untyped parameter as is done for every other Read/Write function (such as the SerReadTimeout overload without a count parameter).
Additional information:
This is not a duplicate of 0034404, which was about the non-standard interface itself.
Mantis conversion info:
- Mantis ID: 38107
- OS: Win32
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 47505 (#96dd5d4f)