Access Violation when filtering on WIdeMemo or Memo fields (TDAMemDataTable)

Hi,

I inadvertently included a datWideMemo field in a TDAMemDataTable.Filter string, and I got an Access Violation:

 Access violation at address 00406B90 in module 'ocAuthorWin.exe'. Read of address 0D762FFB.

I tried both "WIDE_MEMO_FIELD like ‘%text%’ and WIDE_MEMO_FIELD = ‘text’ and both gave the same result.

Not sure if filtering on WideMemo fields is supported or not, but I wouldn’t expect an Access Violation regardless.

madExcept bugreport below for your info.

Cheers

Stuart

  date/time          : 2015-05-22, 09:46:14, 530ms
  computer name      : WIN8VM
  user name          : stuart
  registered owner   : stuart
  operating system   : Windows 8 x64 build 9200
  system language    : English
  system up time     : 22 minutes 38 seconds
  program up time    : 39 seconds
  processors         : 4x Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
  physical memory    : 6430/8192 MB (free/total)
  free disk space    : (C:) 26.65 GB (D:) 28.75 GB
  display mode       : 1920x1015, 32 bit
  process id         : $594
  allocated memory   : 89.18 MB
  largest free block : 1.40 GB
  executable         : ocAuthorWin.exe
  exec. date/time    : 2015-05-22 09:35
  version            : 1.0.18.84
  compiled with      : Delphi XE6
  madExcept version  : 4.0.10
  callstack crc      : $bd499b15, $07054a27, $115b9bc0
  exception number   : 1
  exception class    : EAccessViolation
  exception message  : Access violation at address 00406B90 in module 'ocAuthorWin.exe'. Read of address 0D762FFB.

  main thread ($f8c):
  00406b90 +0a4 ocAuthorWin.exe System              892  +0 Move
  01582e14 +458 ocAuthorWin.exe uDAMemDataset      2503 +69 TDAMemoryDataset.GetVarValueFromBuffer
  01590606 +03a ocAuthorWin.exe uDAMemDataset      7631  +1 TDAFieldFilterExpression.Evaluate
  01591f73 +087 ocAuthorWin.exe uDAMemDataset      8010  +7 TDALikeFilterExpression.Evaluate
  0158f4b9 +0d1 ocAuthorWin.exe uDAMemDataset      7312 +15 TDABinaryFilterExpression.Evaluate
  0158f413 +02b ocAuthorWin.exe uDAMemDataset      7298  +1 TDABinaryFilterExpression.Evaluate
  0158e57c +064 ocAuthorWin.exe uDAMemDataset      7011  +5 TDAFilterEvaluator.EvaluateList
  01587e1c +09c ocAuthorWin.exe uDAMemDataset      4803  +7 TDAMemoryDataset.ApplyFilterFilter
  0158558d +0e1 ocAuthorWin.exe uDAMemDataset      3648 +21 TDAMemoryDataset.DoFilterRecords
  01584cfd +039 ocAuthorWin.exe uDAMemDataset      3396  +4 TDAMemoryDataset.SetFiltered
  015956de +01a ocAuthorWin.exe uDAMemDataTable     937  +1 TDAMemDataTable.SetFiltered
  0171aea1 +48d ocAuthorWin.exe frameSlideChooser1  235 +64 TframeSlideChooser.actApplyFilterExecute
  0054351f +00f ocAuthorWin.exe System.Classes              TBasicAction.Execute
  005a5e5e +086 ocAuthorWin.exe Vcl.ActnList                TCustomAction.Execute
  005433a3 +013 ocAuthorWin.exe System.Classes              TBasicActionLink.Execute
  005c2468 +058 ocAuthorWin.exe Vcl.Controls                TControl.Click
  005e4d16 +01e ocAuthorWin.exe Vcl.StdCtrls                TCustomButton.Click
  00a19e0f +087 ocAuthorWin.exe cxButtons                   TcxCustomButton.Click
  005e581c +010 ocAuthorWin.exe Vcl.StdCtrls                TCustomButton.CNCommand
  00a1a50d +02d ocAuthorWin.exe cxButtons                   TcxCustomButton.CNCommand
  005c1f29 +2bd ocAuthorWin.exe Vcl.Controls                TControl.WndProc
  005c6a41 +5c9 ocAuthorWin.exe Vcl.Controls                TWinControl.WndProc
  005e49c0 +06c ocAuthorWin.exe Vcl.StdCtrls                TButtonControl.WndProc
  00a1a484 +078 ocAuthorWin.exe cxButtons                   TcxCustomButton.WndProc
  0088fb0b +007 ocAuthorWin.exe cxControls                  TcxWindowProcLinkedObject.DefaultProc
  00c3b949 +019 ocAuthorWin.exe dxLayoutContainer           TdxLayoutItem.ControlWndProc
  0088fd8b +007 ocAuthorWin.exe cxControls                  TcxWindowProcLinkedObjectList.WndProc
  005c1b64 +024 ocAuthorWin.exe Vcl.Controls                TControl.Perform
  005c6ba7 +023 ocAuthorWin.exe Vcl.Controls                DoControlMsg
  005c762f +00b ocAuthorWin.exe Vcl.Controls                TWinControl.WMCommand
  005c1f29 +2bd ocAuthorWin.exe Vcl.Controls                TControl.WndProc
  774107d4 +034 ntdll.dll                                   KiUserCallbackDispatcher
  005c1f29 +2bd ocAuthorWin.exe Vcl.Controls                TControl.WndProc
  005c6a41 +5c9 ocAuthorWin.exe Vcl.Controls                TWinControl.WndProc
  0088a19f +13b ocAuthorWin.exe cxControls                  TcxControl.WndProc
  00c15872 +0e2 ocAuthorWin.exe dxLayoutControl             TdxCustomLayoutControl.WndProc
  005c6088 +02c ocAuthorWin.exe Vcl.Controls                TWinControl.MainWndProc
  00544214 +014 ocAuthorWin.exe System.Classes              StdWndProc
  774107d4 +034 ntdll.dll                                   KiUserCallbackDispatcher
  76cce4a4 +134 user32.dll                                  SendMessageW
  76ccddd0 +090 user32.dll                                  CallWindowProcW
  005c6b52 +0e6 ocAuthorWin.exe Vcl.Controls                TWinControl.DefaultHandler
  00a19eae +01a ocAuthorWin.exe cxButtons                   TcxCustomButton.DefaultHandler
  005c28d4 +010 ocAuthorWin.exe Vcl.Controls                TControl.WMLButtonUp
  00544214 +014 ocAuthorWin.exe System.Classes              StdWndProc
  005c1f29 +2bd ocAuthorWin.exe Vcl.Controls                TControl.WndProc
  005c6a41 +5c9 ocAuthorWin.exe Vcl.Controls                TWinControl.WndProc
  005e49c0 +06c ocAuthorWin.exe Vcl.StdCtrls                TButtonControl.WndProc
  00a1a484 +078 ocAuthorWin.exe cxButtons                   TcxCustomButton.WndProc
  0088fb0b +007 ocAuthorWin.exe cxControls                  TcxWindowProcLinkedObject.DefaultProc
  00c3b949 +019 ocAuthorWin.exe dxLayoutContainer           TdxLayoutItem.ControlWndProc
  0088fd8b +007 ocAuthorWin.exe cxControls                  TcxWindowProcLinkedObjectList.WndProc
  005c6088 +02c ocAuthorWin.exe Vcl.Controls                TWinControl.MainWndProc
  00544214 +014 ocAuthorWin.exe System.Classes              StdWndProc
  76cca6db +00b user32.dll                                  DispatchMessageW
  006daa5f +0f3 ocAuthorWin.exe Vcl.Forms                   TApplication.ProcessMessage
  006daaa2 +00a ocAuthorWin.exe Vcl.Forms                   TApplication.HandleMessage
  006dadd5 +0c9 ocAuthorWin.exe Vcl.Forms                   TApplication.Run
  018798ba +0a2 ocAuthorWin.exe ocAuthorWin         106  +8 initialization
  74f17c02 +022 KERNEL32.DLL                                BaseThreadInitThunk

  thread $c04:
  74f17c02 +22 KERNEL32.DLL  BaseThreadInitThunk

  thread $85c:
  74f17c02 +22 KERNEL32.DLL  BaseThreadInitThunk

  thread $a94: <priority:2>
  76cf5de7 +47 user32.dll                GetMessageA
  004acd55 +0d ocAuthorWin.exe madExcept CallThreadProcSafe
  004acdba +32 ocAuthorWin.exe madExcept ThreadExceptFrame
  74f17c02 +22 KERNEL32.DLL              BaseThreadInitThunk
  >> created by main thread ($f8c) at:
  740c5607 +00 winmm.dll

  thread $f60 (TIEStarter):
  74e22cc1 +b1 KERNELBASE.dll                         WaitForSingleObjectEx
  74e22bfd +0d KERNELBASE.dll                         WaitForSingleObject
  00fdaec0 +2c ocAuthorWin.exe iemview        8744 +1 TIEStarter.Execute
  004ace6f +2b ocAuthorWin.exe madExcept              HookedTThreadExecute
  005406c1 +49 ocAuthorWin.exe System.Classes         ThreadProc
  0040adc0 +28 ocAuthorWin.exe System          892 +0 ThreadWrapper
  004acd55 +0d ocAuthorWin.exe madExcept              CallThreadProcSafe
  004acdba +32 ocAuthorWin.exe madExcept              ThreadExceptFrame
  74f17c02 +22 KERNEL32.DLL                           BaseThreadInitThunk
  >> created by main thread ($f8c) at:
  00fdae2e +32 ocAuthorWin.exe iemview        8728 +2 TIEStarter.Create

  thread $dd4 (TIEStarter):
  74e22cc1 +b1 KERNELBASE.dll                         WaitForSingleObjectEx
  74e22bfd +0d KERNELBASE.dll                         WaitForSingleObject
  00fdaec0 +2c ocAuthorWin.exe iemview        8744 +1 TIEStarter.Execute
  004ace6f +2b ocAuthorWin.exe madExcept              HookedTThreadExecute
  005406c1 +49 ocAuthorWin.exe System.Classes         ThreadProc
  0040adc0 +28 ocAuthorWin.exe System          892 +0 ThreadWrapper
  004acd55 +0d ocAuthorWin.exe madExcept              CallThreadProcSafe
  004acdba +32 ocAuthorWin.exe madExcept              ThreadExceptFrame
  74f17c02 +22 KERNEL32.DLL                           BaseThreadInitThunk
  >> created by main thread ($f8c) at:
  00fdae2e +32 ocAuthorWin.exe iemview        8728 +2 TIEStarter.Create

  thread $cf4:
  74f17c02 +22 KERNEL32.DLL  BaseThreadInitThunk

  thread $e38:
  74f17c02 +22 KERNEL32.DLL  BaseThreadInitThunk

  modules:
  00400000 ocAuthorWin.exe      1.0.18.84           D:\Projects\Omnicourse\bin\Win32\Debug
  67fd0000 winrnr.dll           6.3.9600.17415      C:\Windows\System32
  67fe0000 NLAapi.dll           6.3.9600.17415      C:\Windows\system32
  68000000 pnrpnsp.dll          6.3.9600.17415      C:\Windows\system32
  68020000 napinsp.dll          6.3.9600.17415      C:\Windows\system32
  680c0000 rasadhlp.dll         6.3.9600.17415      C:\Windows\System32
  68e90000 DNSAPI.dll           6.3.9600.17415      C:\Windows\SYSTEM32
  699f0000 IdnDL.dll            6.3.9600.17415      C:\Windows\SYSTEM32
  69a00000 Fwpuclnt.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  6a150000 mscms.dll            6.3.9600.17415      C:\Windows\SYSTEM32
  6a1e0000 MSACM32.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  6a200000 MsVfW32.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  6a230000 avifil32.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  6b810000 FaultRep.dll         6.3.9600.17550      C:\Windows\SYSTEM32
  6baf0000 msimg32.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  6c010000 SECUR32.DLL          6.3.9600.17415      C:\Windows\SYSTEM32
  6c020000 security.dll         6.3.9600.16384      C:\Windows\SYSTEM32
  71810000 mswsock.dll          6.3.9600.17415      C:\Windows\System32
  73580000 msxml6.dll           6.30.9600.17415     C:\Windows\SYSTEM32
  73780000 ntmarta.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  738c0000 propsys.dll          7.0.9600.17415      C:\Windows\system32
  73a00000 windowscodecs.dll    6.3.9600.17669      C:\Windows\system32
  73b70000 gdiplus.dll          6.3.9600.17415      C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.9600.17415_none_dad8722c5bcc2d8f
  73d00000 WINSTA.dll           6.3.9600.17415      C:\Windows\SYSTEM32
  73d50000 wtsapi32.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  73d60000 dwmapi.dll           6.3.9600.17415      C:\Windows\system32
  73d80000 kernel.appcore.dll   6.3.9600.17415      C:\Windows\SYSTEM32
  73d90000 uxtheme.dll          6.3.9600.17415      C:\Windows\system32
  73e80000 DEVOBJ.dll           6.3.9600.17415      C:\Windows\SYSTEM32
  73eb0000 SHCORE.DLL           6.3.9600.17666      C:\Windows\SYSTEM32
  73f40000 DCIMAN32.DLL         6.3.9600.17415      C:\Windows\SYSTEM32
  73f50000 WINMMBASE.dll        6.3.9600.17415      C:\Windows\SYSTEM32
  73f80000 profapi.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  740b0000 WINNSI.DLL           6.3.9600.17415      C:\Windows\SYSTEM32
  740c0000 winmm.dll            6.3.9600.17415      C:\Windows\SYSTEM32
  74240000 USERENV.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  74260000 iertutil.dll         11.0.9600.17801     C:\Windows\SYSTEM32
  744a0000 oledlg.dll           6.3.9600.17415      C:\Windows\SYSTEM32
  744c0000 winspool.drv         6.3.9600.17415      C:\Windows\SYSTEM32
  74530000 comctl32.dll         6.10.9600.17784     C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.9600.17784_none_a9f497a901334c74
  74740000 oleacc.dll           7.2.9600.17415      C:\Windows\SYSTEM32
  74870000 SHFolder.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  748a0000 iphlpapi.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  748c0000 wsock32.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  748d0000 wininet.dll          11.0.9600.17801     C:\Windows\SYSTEM32
  74ab0000 version.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  74ac0000 apphelp.dll          6.3.9600.17415      C:\Windows\system32
  74b60000 bcryptPrimitives.dll 6.3.9600.17415      C:\Windows\SYSTEM32
  74bc0000 CRYPTBASE.dll        6.3.9600.17415      C:\Windows\SYSTEM32
  74bd0000 SspiCli.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  74bf0000 advapi32.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  74c70000 sechost.dll          6.3.9600.17734      C:\Windows\SYSTEM32
  74d00000 MSCTF.dll            6.3.9600.17706      C:\Windows\SYSTEM32
  74e20000 KERNELBASE.dll       6.3.9600.17415      C:\Windows\SYSTEM32
  74f00000 KERNEL32.DLL         6.3.9600.17415      C:\Windows\SYSTEM32
  75040000 RPCRT4.dll           6.3.9600.17415      C:\Windows\SYSTEM32
  75100000 combase.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  75280000 clbcatq.dll          2001.12.10530.17415 C:\Windows\SYSTEM32
  75370000 SHLWAPI.dll          6.3.9600.17415      C:\Windows\SYSTEM32
  753c0000 SETUPAPI.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  75580000 comdlg32.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  75620000 shell32.dll          6.3.9600.17680      C:\Windows\SYSTEM32
  76960000 ole32.dll            6.3.9600.17415      C:\Windows\SYSTEM32
  76c00000 NSI.dll              6.3.9600.17415      C:\Windows\SYSTEM32
  76c20000 oleaut32.dll         6.3.9600.17560      C:\Windows\SYSTEM32
  76cc0000 user32.dll           6.3.9600.17415      C:\Windows\SYSTEM32
  76e20000 Normaliz.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  76ea0000 IMM32.DLL            6.3.9600.17415      C:\Windows\system32
  76ee0000 msvcrt.dll           7.0.9600.17415      C:\Windows\SYSTEM32
  76fd0000 gdi32.dll            6.3.9600.17415      C:\Windows\SYSTEM32
  770e0000 cfgmgr32.dll         6.3.9600.17415      C:\Windows\SYSTEM32
  77120000 WS2_32.dll           6.3.9600.17415      C:\Windows\SYSTEM32
  773d0000 ntdll.dll            6.3.9600.17736      C:\Windows\SYSTEM32

Thanks, logged as bugs://72084

bugs://72084 got closed with status fixed.

pls apply this diff:

b39d8bbc44954a811357e14e51da25cb68cdbfa9
 Data Abstract for Delphi/Source/uDAMemDataset.pas | 221 ++++++++++++----------
 1 file changed, 124 insertions(+), 97 deletions(-)

diff --git a/Data Abstract for Delphi/Source/uDAMemDataset.pas b/Data Abstract for Delphi/Source/uDAMemDataset.pas
index 0a44b6d..bed892a 100644
--- a/Data Abstract for Delphi/Source/uDAMemDataset.pas	
+++ b/Data Abstract for Delphi/Source/uDAMemDataset.pas	
@@ -544,0 +545,2 @@ type
+    function GetBLOBRecordFromBuffer(Buffer: PMemDatasetrecord_Native; fld_idx: integer; out blob_size: integer; out blob_data: pointer): PBLOBRecord;overload;
+    function GetBLOBRecordFromBuffer(Buffer: Dataset_PByte; abin2: boolean; fld_idx: integer; out blob_size: integer; out blob_data: pointer): PBLOBRecord;overload;
@@ -2651 +2652,0 @@ var
-  lLen: cardinal;
@@ -2656,0 +2658,2 @@ var
+  blob_size: integer;
+  blob_data: pointer;
@@ -2668,64 +2671,13 @@ begin
-    buf := IntFindFieldData(Buffer,fldIdx,aBin2);
-    case FDataTypeArray[fldIdx] of
-      ftString, ftFixedChar: begin
-        if abin2 and GetStoreStringsAsReference then
-          {$IFDEF NEXTGEN}
-          s := TEncoding.ANSI.GetString(PBytes(Buf)^)
-          {$ELSE}
-          s := PAnsistring(Buf)^
-          {$ENDIF}
-        else
-          {$IFDEF NEXTGEN}
-          s := GetAnsiStringFromPAnsiChar(Buf);
-          {$ELSE}
-          s := Ansistring(PAnsiChar(Buf));
-          {$ENDIF}
-        l := FFieldSizeArray[FldIdx] - Length(s);
-        if (FDataTypeArray[fldIdx] = ftFixedChar) and (l > 0) then
-          s := s + StringOfChar({$IFNDEF NEXTGEN}AnsiChar{$ENDIF}(' '),l);
-        Result := s;
-      end;
-      {$IFDEF DA_FixedWideCharSupport}ftFixedWideChar,{$ENDIF DA_FixedWideCharSupport}
-      ftWideString: begin
-        if abin2 and GetStoreStringsAsReference then
-          us := PUnicodestring(Buf)^
-        else
-          us := UnicodeString(PUnicodeChar(Buf));
-        {$IFDEF DA_FixedWideCharSupport}
-        l := FFieldSizeArray[FldIdx]-Length(us);
-        if (FDataTypeArray[fldIdx] = ftFixedWideChar) and (l > 0) then
-          us := us + StringOfChar(UnicodeChar(' '),l);
-        {$ENDIF DA_FixedWideCharSupport}
-        Result := us;
-      end;
-      ftSmallint: Result := PSmallint(buf)^;
-      ftInteger, ftDate, ftTime, ftAutoInc: Result := PInteger(buf)^;
-      ftWord: Result := PWord(buf)^;
-      ftBoolean: Result := PWordBool(buf)^;
-      ftFloat, ftCurrency: Result := PDouble(Buf)^;
-      ftDateTime: Result := TimeStampToDateTime(MSecsToTimeStamp({$IFDEF FPC}Trunc{$ENDIF}( PDateTime(Buf)^)));
-      ftBcd: Result := PCurrency(buf)^;
-      ftFMTBCD: Result := BCDToVariant(PBcd(buf)^);
-      ftLargeint: Result := PInt64(Buf)^;
-      {$IFNDEF FPC}
-      ftTimeStamp: Result := VarSQLTimeStampCreate(PSQLTimeStamp(Buf)^);
-      {$ENDIF FPC}
-      ftGuid: {$IFDEF NEXTGEN}
-              Result := Copy(GetAnsiStringFromPAnsiChar(Buf), LowString, guidsize);
-              {$ELSE}
-              Result:= AnsiString(PAnsiChar(Buf));
-              {$ENDIF}
-      {$IFDEF DELPHI2009UP}
-      ftLongWord: Result := PLongWord(Buf)^;
-      ftShortint: Result := PShortInt(Buf)^;
-      ftByte:     Result := PByte(Buf)^;
-      ftExtended: Result := PExtended(Buf)^;
-      {$ENDIF}
-      {$IFDEF DELPHI2010UP}
-      ftSingle: Result := PSingle(Buf)^;
-      ftTimeStampOffset: Result := VarSQLTimeStampOffsetCreate(PSQLTimeStampOffset(Buf)^);
-      {$ENDIF}
-
-    else
-      if abin2 then
-        lLen:=PBLOBRecord(buf)^.size
+    if FDataTypeArray[fldIdx] in ft_BlobTypes then begin
+      GetBLOBRecordFromBuffer(Buffer, abin2, FldIdx, blob_size, blob_data);
+      case FDataTypeArray[fldIdx] of
+        ftMemo,ftOraClob: begin
+          SetString(s,PAnsiChar(blob_data),blob_size);
+          Result := s;
+        end;
+        {$IFDEF DA_WideMemoSupport}
+        ftWideMemo: begin
+          SetString(us,PUnicodeChar(blob_data),blob_size div sizeOf(UnicodeChar));
+          Result := us;
+        end;
+        {$ENDIF DA_WideMemoSupport}
@@ -2733,10 +2685,70 @@ begin
-        lLen := GetBin3Offset(Buffer, fldIdx+1)-GetBin3Offset(Buffer, fldIdx);
-      Result := VarArrayCreate([0,lLen-1],varByte);
-      p := VarArrayLock(Result);
-      try
-        if abin2 then
-          move(PBLOBRecord(buf)^.Data, p^,PBLOBRecord(buf)^.size)
-        else
-          Move(buf^, p^, lLen);
-      finally
-        VarArrayUnlock(Result);
+        Result := VarArrayCreate([0,blob_size-1],varByte);
+        p := VarArrayLock(Result);
+        try
+          Move(blob_data^, p^, blob_size);
+        finally
+          VarArrayUnlock(Result);
+        end;
+      end;
+    end
+    else begin
+      buf := IntFindFieldData(Buffer,fldIdx,aBin2);
+      case FDataTypeArray[fldIdx] of
+        ftString, ftFixedChar: begin
+          if abin2 and GetStoreStringsAsReference then
+            {$IFDEF NEXTGEN}
+            s := TEncoding.ANSI.GetString(PBytes(Buf)^)
+            {$ELSE}
+            s := PAnsistring(Buf)^
+            {$ENDIF}
+          else
+            {$IFDEF NEXTGEN}
+            s := GetAnsiStringFromPAnsiChar(Buf);
+            {$ELSE}
+            s := Ansistring(PAnsiChar(Buf));
+            {$ENDIF}
+          l := FFieldSizeArray[FldIdx] - Length(s);
+          if (FDataTypeArray[fldIdx] = ftFixedChar) and (l > 0) then
+            s := s + StringOfChar({$IFNDEF NEXTGEN}AnsiChar{$ENDIF}(' '),l);
+          Result := s;
+        end;
+        {$IFDEF DA_FixedWideCharSupport}ftFixedWideChar,{$ENDIF DA_FixedWideCharSupport}
+        ftWideString: begin
+          if abin2 and GetStoreStringsAsReference then
+            us := PUnicodestring(Buf)^
+          else
+            us := UnicodeString(PUnicodeChar(Buf));
+          {$IFDEF DA_FixedWideCharSupport}
+          l := FFieldSizeArray[FldIdx]-Length(us);
+          if (FDataTypeArray[fldIdx] = ftFixedWideChar) and (l > 0) then
+            us := us + StringOfChar(UnicodeChar(' '),l);
+          {$ENDIF DA_FixedWideCharSupport}
+          Result := us;
+        end;
+        ftSmallint: Result := PSmallint(buf)^;
+        ftInteger, ftDate, ftTime, ftAutoInc: Result := PInteger(buf)^;
+        ftWord: Result := PWord(buf)^;
+        ftBoolean: Result := PWordBool(buf)^;
+        ftFloat, ftCurrency: Result := PDouble(Buf)^;
+        ftDateTime: Result := TimeStampToDateTime(MSecsToTimeStamp({$IFDEF FPC}Trunc{$ENDIF}( PDateTime(Buf)^)));
+        ftBcd: Result := PCurrency(buf)^;
+        ftFMTBCD: Result := BCDToVariant(PBcd(buf)^);
+        ftLargeint: Result := PInt64(Buf)^;
+        {$IFNDEF FPC}
+        ftTimeStamp: Result := VarSQLTimeStampCreate(PSQLTimeStamp(Buf)^);
+        {$ENDIF FPC}
+        ftGuid: {$IFDEF NEXTGEN}
+                Result := Copy(GetAnsiStringFromPAnsiChar(Buf), LowString, guidsize);
+                {$ELSE}
+                Result:= AnsiString(PAnsiChar(Buf));
+                {$ENDIF}
+        {$IFDEF DELPHI2009UP}
+        ftLongWord: Result := PLongWord(Buf)^;
+        ftShortint: Result := PShortInt(Buf)^;
+        ftByte:     Result := PByte(Buf)^;
+        ftExtended: Result := PExtended(Buf)^;
+        {$ENDIF}
+        {$IFDEF DELPHI2010UP}
+        ftSingle: Result := PSingle(Buf)^;
+        ftTimeStampOffset: Result := VarSQLTimeStampOffsetCreate(PSQLTimeStampOffset(Buf)^);
+        {$ENDIF}
@@ -5797,0 +5810,36 @@ end;
+function TDAMemoryDataset.GetBLOBRecordFromBuffer(Buffer: Dataset_PByte;
+  abin2: boolean; fld_idx: integer; out blob_size: integer;
+  out blob_data: pointer): PBLOBRecord;
+begin
+  if abin2 then begin
+      Result := PPointer(IntFindFieldData(Buffer, fld_idx, True))^;
+      if Result <> nil then begin
+        blob_data := @Result^.Data;
+        blob_size := Result^.size;
+      end
+      else begin
+        blob_data := nil;
+        blob_size := 0;
+      end;
+  end
+  else begin
+    blob_size := GetBin3Offset(Buffer,fld_idx+1)-GetBin3Offset(Buffer,fld_idx);
+    blob_data := IntFindFieldData(Buffer, fld_idx, False);
+    Result := nil;
+  end;
+end;
+
+function TDAMemoryDataset.GetBLOBRecordFromBuffer(
+  Buffer: PMemDatasetrecord_Native; fld_idx: integer; out blob_size: integer;
+  out blob_data: pointer): PBLOBRecord;
+begin
+  case Buffer^.Ident of
+    mrBin2Style: Result := GetBLOBRecordFromBuffer(Buffer^.Data,true,fld_idx,blob_size,blob_data);
+    mrBin3Style: Result := GetBLOBRecordFromBuffer(Buffer^.Data,false,fld_idx,blob_size,blob_data);
+  else
+    blob_data := nil;
+    blob_size := 0;
+    Result := nil;
+  end;
+end;
+
@@ -6582,22 +6630 @@ begin
-  case Buffer^.Ident of
-    mrBin2Style: begin
-      Result := PPointer(FDataSet.IntFindFieldData(Buffer^.Data, ffld_idx, True))^;
-      if Result <> nil then begin
-        blob_data := @Result^.Data;
-        blob_size := Result^.size;
-      end
-      else begin
-        blob_data := nil;
-        blob_size := 0;
-      end;
-    end;
-    mrBin3Style: begin
-      blob_size := FDataSet.GetBin3Offset(Buffer^.Data,ffld_idx+1)-FDataSet.GetBin3Offset(Buffer^.Data,ffld_idx);
-      blob_data := FDataSet.IntFindFieldData(Buffer^.Data, ffld_idx, False);
-      Result := nil;
-    end;
-  else
-    blob_data := nil;
-    blob_size := 0;
-    Result := nil;
-  end;
+  Result := FDataSet.GetBLOBRecordFromBuffer(Buffer,ffld_idx, blob_size, blob_data);

Thanks guys, that was quick :slight_smile:

Hi
I’m having problems apply the diff file. I copied and pasted your diff into a .diff file and I used

git apply uDAMemDataset.diff

and I got:

fatal: corrupt patch at line 236

then I tried a search & replace in the diff file, to replace CR/LF with just LF’s. Tried again and I get:

error: patch failed: DataAbstract for Delphi/Source/UDAMemDataset.pass:2651
error: DataAbstract for Delphi/Source/UDAMemDataset.pass:2651: patch does not apply

Would it be possible to mail me a new uDAMemDataset.pas file – might be easier?

Cheers
Stu

drop request to support@ or wait a bit - we are creating interim release. this fix will be also included into it.

Ok, I’ll wait for the interim relese – do you know roughly how long? Cheers

it should be tomorrow

1 Like

we released 8.3.91.1167

1 Like

Got it thanks, problem solved.