View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0035164||Lazarus||TAChart||public||2019-02-27 23:59||2019-02-28 21:51|
|Reporter||Marcin Wiazowski||Assigned To||wp|
|Product Version||2.1 (SVN)||Product Build||60526|
|Target Version||2.2||Fixed in Version|
|Summary||0035164: TAChart: lack of validation in TFitSeries.SetParamCount|
|Description||Launch the attached Reproduce application and press the "Test" button: ERangeError exception is generated; it's not nice to have out-of-range operations. The series disappears from the chart.|
The cause is that the code makes a thing, that should be impossible: it sets TFitSeries.ParamCount to zero. In any case, ParamCount must be at lest 1 - in this case the interpolated equation will be: y = const.
The attached patch does not allow to set ParamCount to zero - in this case the operation is ignored; this is same as currently when FitEquation is feLinear, feExp or fePower - in this case the operation is also ignored, and the previous value is not changed (this is because feLinear, feExp and fePower require ParamCount tied to 2).
As can be seen in the Object Inspector, when TFitSeries has its FitEquation property set to feLinear, feExp or fePower, trying to change the ParamCount property, makes it returning immediately to 2.
After applying the patch, similar behavior is also when FitEquation property is set to fePolynomial or feCustom, when trying to set the ParamCount property to 0 - it returns immediately to its previous value.
|Tags||No tags attached.|
|Fixed in Revision||60534|
Reproduce.zip (2,439 bytes)
patch.diff (566 bytes)
Index: components/tachart/tafuncseries.pas =================================================================== --- components/tachart/tafuncseries.pas (revision 60526) +++ components/tachart/tafuncseries.pas (working copy) @@ -2093,7 +2093,7 @@ procedure TFitSeries.SetParamCount(AValue: Integer); begin - if (AValue = ParamCount) or not (FFitEquation in [fePolynomial, feCustom]) then + if (AValue = ParamCount) or (AValue <= 0) or not (FFitEquation in [fePolynomial, feCustom]) then exit; SetLength(FFitParams, AValue); FState := fpsUnknown;
patch.diff (566 bytes)
Thank you. Instead of silently ignoring the value, I decided to raise an exception in order to signal the user that something was wrong.
||Fix confirmed. Thanks!|
|2019-02-27 23:59||Marcin Wiazowski||New Issue|
|2019-02-27 23:59||Marcin Wiazowski||File Added: Reproduce.zip|
|2019-02-28 00:00||Marcin Wiazowski||File Added: patch.diff|
|2019-02-28 00:26||Maxim Ganetsky||Assigned To||=> wp|
|2019-02-28 00:26||Maxim Ganetsky||Status||new => assigned|
|2019-02-28 16:07||wp||Note Added: 0114507|
|2019-02-28 16:08||wp||Fixed in Revision||=> 60534|
|2019-02-28 16:08||wp||LazTarget||=> 2.2|
|2019-02-28 16:08||wp||Status||assigned => resolved|
|2019-02-28 16:08||wp||Resolution||open => fixed|
|2019-02-28 16:08||wp||Target Version||=> 2.2|
|2019-02-28 16:08||wp||Note Edited: 0114507||View Revisions|
|2019-02-28 21:51||Marcin Wiazowski||Note Added: 0114525|
|2019-02-28 21:51||Marcin Wiazowski||Status||resolved => closed|