Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-04

TDataset.ClearCalcFields

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

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

Reply by email