-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory corruption due to invalid column position in DFM file #1179
Comments
Please respect our guidelines on the project homepage for submitting bugs. Please include your version of Virtual TreeView and Delphi, and attach a sample compiling project as ZIP to your report, or instructions how to modify one of the included sample projects to reproduce the problem. From the call stack it is hard to tell what went wrong. |
How exactly did that happen? |
There were more columns, with custom positions set. Then some of the columns were removed, but invalid positions for the remaining stayed. |
I use latest Delphi 11.3, and the latest release version of Virtual Trees. Attached is an example project. |
I see, the invalid position was written to the DFM file. Was this DFM file created with Virtual TreeView V7.6.3? Please try if my fix solves the issue in your project. It does for the attached sample project. |
Thank you, the fix worked! |
There appears to be a bug with reading columns. If "Columns" property contains columns with Position = N where, for some of the columns, N is larger than valid column index, there's memory corruption.
Following is the log from FastMM in full debug mode (there were 6 columns, and for column at index 3, Position was set to 7):
Memory Corruption Detected
A memory block footer has been corrupted.
The block size is 36.
The block was allocated by thread 0x3520, and the stack trace (return addresses) at the time was:
00420622 [FastMM5.pas][FastMM5][FastMM_DebugGetMem$qqri][7781]
0040733D [System.pas][System][@ReallocMem$qqrrpvi][5141]
0040E8E7 [System.pas][System][DynArraySetLength$qqrrpvpvipi][36790]
004072EA [System.pas][System][@FreeMEM$qqrpv][4997]
0040EA4E [System.pas][System][@DynArraySetLength$qqrv][36895]
00A3C48C [VirtualTrees.pas][VirtualTrees][TVirtualTreeColumns.InitializePositionArray][8355]
00A3C687 [VirtualTrees.pas][VirtualTrees][TVirtualTreeColumns.EndUpdate][8432]
00545589 [System.Classes.pas][System.Classes][Classes.TReader.ReadCollection][11210]
00A41819 [VirtualTrees.pas][VirtualTrees][TVTHeader.ReadColumns][11049]
00544642 [System.Classes.pas][System.Classes][Classes.TReader.DefineProperty][10608]
00A5159C [VirtualTrees.pas][VirtualTrees][TBaseVirtualTree.DefineProperties][18911]
00A6FFAC [VirtualTrees.pas][VirtualTrees][TCustomVirtualStringTree.DefineProperties][34145]
005463B9 [System.Classes.pas][System.Classes][Classes.TReader.ReadProperty][11627]
00545CDE [System.Classes.pas][System.Classes][Classes.TReader.ReadDataInner][11391]
005EFCF6 [Vcl.Controls.pas][Vcl.Controls][Controls.TWinControl.SetParent][14251]
00545CBE [System.Classes.pas][System.Classes][Classes.TReader.ReadData][11384]
00553702 [System.Classes.pas][System.Classes][Classes.TComponent.ReadState][17354]
005E2878 [Vcl.Controls.pas][Vcl.Controls][Controls.TControl.ReadState][5823]
005E740E [Vcl.Controls.pas][Vcl.Controls][Controls.TWinControl.ReadState][8916]
00545B0A [System.Classes.pas][System.Classes][Classes.TReader.ReadComponent][11345]
The text was updated successfully, but these errors were encountered: