[fpc-devel] TDataset.ClearCalcFields

petr.kristan at epos.cz petr.kristan at epos.cz
Tue Apr 1 15:27:31 CEST 2008


Hi.

Valgrind uncover me error in TDataset.ClearCalcFields.
I think that this code is entirely bad.

 Procedure TDataset.ClearCalcFields(Buffer: PChar);
 
 begin
  if FCalcFieldsSize > 0 then
    FillByte((Buffer+RecordSize)^,FCalcFieldsSize,0);
 end;

With ZEOSDB this code clears data behind allocated buffer. Buffer size
is here RecordSize.

For allocating buffers is responsible overrided method
AllocRecordBuffer. And I think that for clearing calc fields must be 
responsible overrided method ClearCalcFields too if driver requires it. Not this code
in base class. I suggest this patch:

Index: packages/fcl-db/src/base/dataset.inc
===================================================================
--- packages/fcl-db/src/base/dataset.inc        (revision 10565)
+++ packages/fcl-db/src/base/dataset.inc        (working copy)
@@ -180,8 +180,6 @@
 Procedure TDataset.ClearCalcFields(Buffer: PChar);
 
 begin
-  if FCalcFieldsSize > 0 then
-    FillByte((Buffer+RecordSize)^,FCalcFieldsSize,0);
 end;
 
 Procedure TDataset.CloseBlob(Field: TField);


For me this solves problems with SIGSEGV.
I look into Borland TDataset.ClearCalcFields implementation and here is this method
empty too.

Petr

-- 
Ing. Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223    Czech Republic (Eastern Europe) 
fax: +420 466510709



More information about the fpc-devel mailing list