View Issue Details

IDProjectCategoryView StatusLast Update
0036171PatchesWidgetsetpublic2019-10-14 21:27
ReporterC WesternAssigned ToDmitry Boyarintsev 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.0.5 (SVN)Product Build 
Target VersionFixed in Version 
Summary0036171: Range check errors in Cocoa widget set
DescriptionExperimenting with cocoa with various applications revealed some range check errors if the widget set was compiled with them on. The attached patch includes possible fixes
TagsNo tags attached.
Fixed in Revision62052
LazTarget-
WidgetsetCocoa
Attached Files
  • range.patch (2,263 bytes)
    diff -uwNr --exclude=.svn --exclude=Makefile --exclude=Makefile.fpc --exclude=Makefile.compiled --exclude='*.rsj' --exclude='*.bak' --exclude='*.po' lazarus/lcl/interfaces/cocoa/cocoawinapi.inc lazarus.w/lcl/interfaces/cocoa/cocoawinapi.inc
    --- lazarus/lcl/interfaces/cocoa/cocoawinapi.inc	2019-09-01 15:29:24.000000000 +0100
    +++ lazarus.w/lcl/interfaces/cocoa/cocoawinapi.inc	2019-10-12 21:17:24.000000000 +0100
    @@ -1941,7 +1941,7 @@
     
     
     type
    -  TPointArray = array [word] of TPoint;
    +  TPointArray = array [dword] of TPoint;
       PPointArray = ^TPointArray;
     
     function TCocoaWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
    diff -uwNr --exclude=.svn --exclude=Makefile --exclude=Makefile.fpc --exclude=Makefile.compiled --exclude='*.rsj' --exclude='*.bak' --exclude='*.po' lazarus/lcl/interfaces/cocoa/cocoawsclipboard.pas lazarus.w/lcl/interfaces/cocoa/cocoawsclipboard.pas
    --- lazarus/lcl/interfaces/cocoa/cocoawsclipboard.pas	2019-09-01 15:29:24.000000000 +0100
    +++ lazarus.w/lcl/interfaces/cocoa/cocoawsclipboard.pas	2019-10-12 16:41:38.000000000 +0100
    @@ -347,6 +347,7 @@
           begin
             DataStream.Position := 0;
             SetLength(lText, DataStream.Size);
    +        if DataStream.Size > 0 then
             DataStream.Read(lText[1], DataStream.Size);
             lNSText := NSStringUtf8(lText);
     
    diff -uwNr --exclude=.svn --exclude=Makefile --exclude=Makefile.fpc --exclude=Makefile.compiled --exclude='*.rsj' --exclude='*.bak' --exclude='*.po' lazarus/lcl/interfaces/cocoa/cocoawscommon.pas lazarus.w/lcl/interfaces/cocoa/cocoawscommon.pas
    --- lazarus/lcl/interfaces/cocoa/cocoawscommon.pas	2019-09-01 15:29:24.000000000 +0100
    +++ lazarus.w/lcl/interfaces/cocoa/cocoawscommon.pas	2019-10-12 20:22:24.000000000 +0100
    @@ -173,7 +173,7 @@
     implementation
     
     uses
    -  CocoaInt;
    +  Math, CocoaInt;
     
     var
       LastMouse: TLastMouseInfo;
    @@ -1232,8 +1232,8 @@
       // then send a LM_SIZE message
       if Resized or ClientResized then
       begin
    -    LCLSendSizeMsg(Target, NewBounds.Right - NewBounds.Left,
    -      NewBounds.Bottom - NewBounds.Top, Owner.lclWindowState, True);
    +    LCLSendSizeMsg(Target, Max(NewBounds.Right - NewBounds.Left,0),
    +      Max(NewBounds.Bottom - NewBounds.Top,0), Owner.lclWindowState, True);
       end;
     
       // then send a LM_MOVE message
    
    range.patch (2,263 bytes)

Activities

C Western

2019-10-13 11:15

reporter  

range.patch (2,263 bytes)
diff -uwNr --exclude=.svn --exclude=Makefile --exclude=Makefile.fpc --exclude=Makefile.compiled --exclude='*.rsj' --exclude='*.bak' --exclude='*.po' lazarus/lcl/interfaces/cocoa/cocoawinapi.inc lazarus.w/lcl/interfaces/cocoa/cocoawinapi.inc
--- lazarus/lcl/interfaces/cocoa/cocoawinapi.inc	2019-09-01 15:29:24.000000000 +0100
+++ lazarus.w/lcl/interfaces/cocoa/cocoawinapi.inc	2019-10-12 21:17:24.000000000 +0100
@@ -1941,7 +1941,7 @@
 
 
 type
-  TPointArray = array [word] of TPoint;
+  TPointArray = array [dword] of TPoint;
   PPointArray = ^TPointArray;
 
 function TCocoaWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
diff -uwNr --exclude=.svn --exclude=Makefile --exclude=Makefile.fpc --exclude=Makefile.compiled --exclude='*.rsj' --exclude='*.bak' --exclude='*.po' lazarus/lcl/interfaces/cocoa/cocoawsclipboard.pas lazarus.w/lcl/interfaces/cocoa/cocoawsclipboard.pas
--- lazarus/lcl/interfaces/cocoa/cocoawsclipboard.pas	2019-09-01 15:29:24.000000000 +0100
+++ lazarus.w/lcl/interfaces/cocoa/cocoawsclipboard.pas	2019-10-12 16:41:38.000000000 +0100
@@ -347,6 +347,7 @@
       begin
         DataStream.Position := 0;
         SetLength(lText, DataStream.Size);
+        if DataStream.Size > 0 then
         DataStream.Read(lText[1], DataStream.Size);
         lNSText := NSStringUtf8(lText);
 
diff -uwNr --exclude=.svn --exclude=Makefile --exclude=Makefile.fpc --exclude=Makefile.compiled --exclude='*.rsj' --exclude='*.bak' --exclude='*.po' lazarus/lcl/interfaces/cocoa/cocoawscommon.pas lazarus.w/lcl/interfaces/cocoa/cocoawscommon.pas
--- lazarus/lcl/interfaces/cocoa/cocoawscommon.pas	2019-09-01 15:29:24.000000000 +0100
+++ lazarus.w/lcl/interfaces/cocoa/cocoawscommon.pas	2019-10-12 20:22:24.000000000 +0100
@@ -173,7 +173,7 @@
 implementation
 
 uses
-  CocoaInt;
+  Math, CocoaInt;
 
 var
   LastMouse: TLastMouseInfo;
@@ -1232,8 +1232,8 @@
   // then send a LM_SIZE message
   if Resized or ClientResized then
   begin
-    LCLSendSizeMsg(Target, NewBounds.Right - NewBounds.Left,
-      NewBounds.Bottom - NewBounds.Top, Owner.lclWindowState, True);
+    LCLSendSizeMsg(Target, Max(NewBounds.Right - NewBounds.Left,0),
+      Max(NewBounds.Bottom - NewBounds.Top,0), Owner.lclWindowState, True);
   end;
 
   // then send a LM_MOVE message
range.patch (2,263 bytes)

Dmitry Boyarintsev

2019-10-14 02:10

developer   ~0118575

Last edited: 2019-10-14 02:10

View 2 revisions

applied with modifications.
please test and close if ok.

note that
TPointArray = array [dword] of TPoint
will not compile for i386

Issue History

Date Modified Username Field Change
2019-10-13 11:15 C Western New Issue
2019-10-13 11:15 C Western File Added: range.patch
2019-10-13 12:13 Bart Broersma Assigned To => Dmitry Boyarintsev
2019-10-13 12:13 Bart Broersma Status new => assigned
2019-10-14 02:10 Dmitry Boyarintsev Status assigned => resolved
2019-10-14 02:10 Dmitry Boyarintsev Resolution open => fixed
2019-10-14 02:10 Dmitry Boyarintsev Fixed in Revision => 62052
2019-10-14 02:10 Dmitry Boyarintsev LazTarget => -
2019-10-14 02:10 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2019-10-14 02:10 Dmitry Boyarintsev Note Added: 0118575
2019-10-14 02:10 Dmitry Boyarintsev Note Edited: 0118575 View Revisions
2019-10-14 21:27 C Western Status resolved => closed