Menu

#457 Possible Range Check Error in SynUnicode

Not Fixed
open
nobody
None
5
2015-02-02
2015-02-02
Arun Ravi
No

The error could occur in the constructor of the TWideFileStream(version accepting three arguments) class.

  • The constructor TWideFileStream.Create calls the inherited constructor(THandleStream) with the results of WideFileOpen and WideFileCreate, both of which return signed integers.
  • The expected type for inherited constructor itself is a THandle, which is currently a NativeUInt. A negeative value would cause a range-check error here.

Problems could occur in the following cases:

  • The WideFileOpen returns a negeative value by default.
  • When the calls to CreateFile from WideFileCreate and WideFileOpen fail, the return value would be INVALID_HANDLE_VALUE, which casted to an integer would be -1.

Could you please change the return types of the routines WideFileCreate (both overloaded variants) and WideFileOpen to THandle?

Discussion


Log in to post a comment.