mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 15:19:21 +02:00
TAChart: Prevent out-of-range access with AccumulationRange=0 and AccumulationMethod=camDerivative
git-svn-id: trunk@32205 -
This commit is contained in:
parent
643751d975
commit
50521088ff
@ -164,7 +164,7 @@ type
|
|||||||
TCalculatedChartSource = class(TCustomChartSource)
|
TCalculatedChartSource = class(TCustomChartSource)
|
||||||
private
|
private
|
||||||
FAccumulationMethod: TChartAccumulationMethod;
|
FAccumulationMethod: TChartAccumulationMethod;
|
||||||
FAccumulationRange: Integer;
|
FAccumulationRange: Cardinal;
|
||||||
FHistory: TChartSourceBuffer;
|
FHistory: TChartSourceBuffer;
|
||||||
FIndex: Integer;
|
FIndex: Integer;
|
||||||
FItem: TChartDataItem;
|
FItem: TChartDataItem;
|
||||||
@ -181,7 +181,7 @@ type
|
|||||||
procedure Changed(ASender: TObject);
|
procedure Changed(ASender: TObject);
|
||||||
procedure ExtractItem(out AItem: TChartDataItem; AIndex: Integer);
|
procedure ExtractItem(out AItem: TChartDataItem; AIndex: Integer);
|
||||||
procedure SetAccumulationMethod(AValue: TChartAccumulationMethod);
|
procedure SetAccumulationMethod(AValue: TChartAccumulationMethod);
|
||||||
procedure SetAccumulationRange(AValue: Integer);
|
procedure SetAccumulationRange(AValue: Cardinal);
|
||||||
procedure SetOrigin(AValue: TCustomChartSource);
|
procedure SetOrigin(AValue: TCustomChartSource);
|
||||||
procedure SetPercentage(AValue: Boolean);
|
procedure SetPercentage(AValue: Boolean);
|
||||||
procedure SetReorderYList(const AValue: String);
|
procedure SetReorderYList(const AValue: String);
|
||||||
@ -198,7 +198,7 @@ type
|
|||||||
published
|
published
|
||||||
property AccumulationMethod: TChartAccumulationMethod
|
property AccumulationMethod: TChartAccumulationMethod
|
||||||
read FAccumulationMethod write SetAccumulationMethod default camNone;
|
read FAccumulationMethod write SetAccumulationMethod default camNone;
|
||||||
property AccumulationRange: Integer
|
property AccumulationRange: Cardinal
|
||||||
read FAccumulationRange write SetAccumulationRange default 2;
|
read FAccumulationRange write SetAccumulationRange default 2;
|
||||||
|
|
||||||
property Origin: TCustomChartSource read FOrigin write SetOrigin;
|
property Origin: TCustomChartSource read FOrigin write SetOrigin;
|
||||||
@ -817,6 +817,9 @@ procedure TCalculatedChartSource.CalcAccumulation(AIndex: Integer);
|
|||||||
var
|
var
|
||||||
i, ar: Integer;
|
i, ar: Integer;
|
||||||
begin
|
begin
|
||||||
|
if (AccumulationMethod = camDerivative) and (AccumulationRange = 0) then
|
||||||
|
FHistory.Capacity := 10
|
||||||
|
else
|
||||||
FHistory.Capacity := AccumulationRange;
|
FHistory.Capacity := AccumulationRange;
|
||||||
ar := IfThen(AccumulationRange = 0, MaxInt, AccumulationRange);
|
ar := IfThen(AccumulationRange = 0, MaxInt, AccumulationRange);
|
||||||
if FIndex = AIndex - 1 then begin
|
if FIndex = AIndex - 1 then begin
|
||||||
@ -993,7 +996,7 @@ begin
|
|||||||
Changed(nil);
|
Changed(nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCalculatedChartSource.SetAccumulationRange(AValue: Integer);
|
procedure TCalculatedChartSource.SetAccumulationRange(AValue: Cardinal);
|
||||||
begin
|
begin
|
||||||
if FAccumulationRange = AValue then exit;
|
if FAccumulationRange = AValue then exit;
|
||||||
FAccumulationRange := AValue;
|
FAccumulationRange := AValue;
|
||||||
|
Loading…
Reference in New Issue
Block a user