View Issue Details

IDProjectCategoryView StatusLast Update
0004285JEDI VCL00 JVCL Componentspublic2007-12-16 12:58
ReporterlocopabloAssigned ToAHUser 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.32 
Target VersionFixed in Version3.34 
Summary0004285: TJvMemoryData causes access violation when assigning a WideString value to a TWideStringField
DescriptionAssigning a value to a WideString field causes an access violation.

Sample code:

memds := TJvMemoryData.Create(nil);
try
  memds.FieldDefs.Add('ss', ftString, 20, False);
  memds.FieldDefs.Add('ws', ftWideString, 20, False);
  memds.Active := True;
  memds.Append;
  memds.Fields[0].Value := 'abc123';
// next line causes A/V
  memds.Fields[1].Value := 'abc123';
  memds.Post;
finally
  FreeAndNil(memds);
end;


Additional InformationFailure seems to be caused by this function:

procedure TJvMemoryData.DataConvert(Field: TField; Source, Dest: Pointer; ToNative: Boolean);
begin
  if Field.DataType = ftWideString then
  begin
    // copied from DB.PAS - this works OK
    WStrCopy(PWideChar(Dest), PWideChar(Source));
    { // Original code - crashes with A/V
    if ToNative then
    begin
      Word(Dest^) := Length(PWideString(Source)^) * 2;
      Move(PWideChar(Source^)^, (PWideChar(Dest) + 1)^, Word(Dest^));
    end
    else
      SetString(WideString(Dest^), PWideChar(PChar(Source) + 2), Word(Source^) div 2);
    }
  end
  else
    inherited DataConvert(Field, Source, Dest, ToNative);
end;

TagsNo tags attached.

Relationships

has duplicate 0004412 resolvedAHUser unit jvMemoryDataset 

Activities

locopablo

2007-11-07 08:27

reporter   ~0014024

It seems the internal data handling has changed quite a bit between versions and the code above does not make BDS2006 very happy... BDS 2006 includes its own internal storage of WideString data, which uses the WStrCopy() function.

Adding an ifdef to the DataConvert function makes WideString value assignemt work for both BDS2006 and Delphi 5.

interface

...TJvMemoryData...
{$IFNDEF DELPHI10_UP}
  procedure DataConvert(Field: TField; Source, Dest: Pointer; ToNative: Boolean);
end;
{$ENDIF}

implementation

{$IFNDEF DELPHI10_UP}
procedure TJvMemoryData.DataConvert(Field: TField; Source, Dest: Pointer; ToNative: Boolean);
begin
...
end;
{$ENDIF}

AHUser

2007-12-16 12:58

developer   ~0014067

Fixed in SVN.

Issue History

Date Modified Username Field Change
2007-10-31 12:54 locopablo New Issue
2007-11-07 08:27 locopablo Note Added: 0014024
2007-12-16 12:58 AHUser Status new => resolved
2007-12-16 12:58 AHUser Fixed in Version => Daily / SVN
2007-12-16 12:58 AHUser Resolution open => fixed
2007-12-16 12:58 AHUser Assigned To => AHUser
2007-12-16 12:58 AHUser Note Added: 0014067
2008-11-02 12:34 AHUser Relationship added has duplicate 0004412