View Issue Details

IDProjectCategoryView StatusLast Update
0026396LazarusWidgetsetpublic2014-11-06 12:59
ReporterPetr-KAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWin32OSOS Version
Product Version1.3 (SVN)Product Buildtrunk #45123 
Target VersionFixed in Version1.2.6 
Summary0026396: Range check error in SetCaretPos in Memo
DescriptionIf NewPos is beyond number of lines in memo, then
SendMessageW(ACustomEdit.Handle, EM_LINEINDEX, NewPos.Y, 0) returns -1

I only change type CharIndex from LongWord to LongInt.
Patch is included.
TagsNo tags attached.
Fixed in Revisionr45721, r45724
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • win32wsstdctrls.patch (513 bytes)
    Index: win32wsstdctrls.pp
    ===================================================================
    --- win32wsstdctrls.pp	(revision 45123)
    +++ win32wsstdctrls.pp	(working copy)
    @@ -1340,7 +1340,7 @@
     
     class procedure TWin32WSCustomMemo.SetCaretPos(const ACustomEdit: TCustomEdit; const NewPos: TPoint);
     var
    -  CharIndex: Longword;
    +  CharIndex: Longint;
     begin
       { EM_LINEINDEX returns the char index of a given line }
       CharIndex := Windows.SendMessageW(ACustomEdit.Handle, EM_LINEINDEX, NewPos.Y, 0) + NewPos.X;
    
    win32wsstdctrls.patch (513 bytes)

Activities

Petr-K

2014-06-26 11:22

reporter  

win32wsstdctrls.patch (513 bytes)
Index: win32wsstdctrls.pp
===================================================================
--- win32wsstdctrls.pp	(revision 45123)
+++ win32wsstdctrls.pp	(working copy)
@@ -1340,7 +1340,7 @@
 
 class procedure TWin32WSCustomMemo.SetCaretPos(const ACustomEdit: TCustomEdit; const NewPos: TPoint);
 var
-  CharIndex: Longword;
+  CharIndex: Longint;
 begin
   { EM_LINEINDEX returns the char index of a given line }
   CharIndex := Windows.SendMessageW(ACustomEdit.Handle, EM_LINEINDEX, NewPos.Y, 0) + NewPos.X;
win32wsstdctrls.patch (513 bytes)

Juha Manninen

2014-06-28 22:17

developer   ~0075919

Please test.

Bart Broersma

2014-06-29 00:04

developer   ~0075925

Shouldn't that be LRESULT, or if we want to use a "pascallish" type PtrInt?
The result of SendMessageW is of type LResult.
MS says: "LRESULT: Signed result of message processing. This type is declared in WinDef.h as follows: typedef LONG_PTR"

Juha Manninen

2014-06-29 00:16

developer   ~0075927

Assigning to you Bart. You work more on Windows anyways.

Bart Broersma

2014-06-29 00:44

developer   ~0075930

Please close if OK.

Issue History

Date Modified Username Field Change
2014-06-26 11:22 Petr-K New Issue
2014-06-26 11:22 Petr-K File Added: win32wsstdctrls.patch
2014-06-28 22:17 Juha Manninen Fixed in Revision => r45721
2014-06-28 22:17 Juha Manninen LazTarget => -
2014-06-28 22:17 Juha Manninen Note Added: 0075919
2014-06-28 22:17 Juha Manninen Status new => resolved
2014-06-28 22:17 Juha Manninen Resolution open => fixed
2014-06-28 22:17 Juha Manninen Assigned To => Juha Manninen
2014-06-29 00:04 Bart Broersma Note Added: 0075925
2014-06-29 00:04 Bart Broersma Status resolved => assigned
2014-06-29 00:04 Bart Broersma Resolution fixed => reopened
2014-06-29 00:15 Juha Manninen Assigned To Juha Manninen => Bart Broersma
2014-06-29 00:16 Juha Manninen Note Added: 0075927
2014-06-29 00:44 Bart Broersma Fixed in Revision r45721 => r45721, r45724
2014-06-29 00:44 Bart Broersma Note Added: 0075930
2014-06-29 00:44 Bart Broersma Status assigned => resolved
2014-06-29 00:44 Bart Broersma Resolution reopened => fixed
2014-06-29 00:47 Bart Broersma Fixed in Version => 1.2.6
2014-11-06 12:59 Petr-K Status resolved => closed