View Issue Details

IDProjectCategoryView StatusLast Update
0035164LazarusTAChartpublic2019-02-28 21:51
ReporterMarcin WiazowskiAssigned Towp 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.1 (SVN)Product Build60526 
Target Version2.2Fixed in Version 
Summary0035164: TAChart: lack of validation in TFitSeries.SetParamCount
DescriptionLaunch 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.
TagsNo tags attached.
Fixed in Revision60534
LazTarget2.2
WidgetsetWin32/Win64
Attached Files
  • 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)

Activities

Marcin Wiazowski

2019-02-27 23:59

reporter  

Reproduce.zip (2,439 bytes)

Marcin Wiazowski

2019-02-28 00:00

reporter  

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)

wp

2019-02-28 16:07

developer   ~0114507

Last edited: 2019-02-28 16:08

View 2 revisions

Thank you. Instead of silently ignoring the value, I decided to raise an exception in order to signal the user that something was wrong.

Marcin Wiazowski

2019-02-28 21:51

reporter   ~0114525

Fix confirmed. Thanks!

Issue History

Date Modified Username Field Change
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