ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBOutputBlock.pas
(Generate patch)

Comparing ibx/trunk/fbintf/client/FBOutputBlock.pas (file contents):
Revision 143 by tony, Fri Feb 23 12:11:21 2018 UTC vs.
Revision 209 by tony, Wed Mar 14 12:48:51 2018 UTC

# Line 302 | Line 302 | implementation
302  
303   uses FBMessages {$IFNDEF FPC}, TypInfo {$ENDIF};
304  
305 + function BufToStr(P: PByte; Len: integer):AnsiString;
306 + begin
307 +  SetLength(Result,Len);
308 +  Move(P^,Result[1],Len);
309 + end;
310 +
311   {$IFDEF FPC}
312   { TOutputBlockItemGroup }
313  
# Line 424 | Line 430 | end;
430   procedure TOutputBlockItem.SetString(out S: AnsiString; Buf: PByte;
431    Len: integer; CodePage: TSystemCodePage);
432   var rs: RawByteString;
433 +    i: integer;
434   begin
435 <  system.SetString(rs,PAnsiChar(Buf),len);
435 >  {There seems to be a memory manager problem with SetString that can cause
436 >   an unhandled exception at the end of a program if it is used to set the
437 >   string. Safer to copy characters one by one. Note that Setlength does
438 >   not work around the bug either.}
439 >  rs := '';
440 >  for i := 0 to len-1 do
441 >    rs := rs + PAnsiChar(buf+i)^;
442 > //  system.SetString(rs,PAnsiChar(Buf),len);
443    SetCodePage(rs,CodePage,false);
444    S := rs;
445   end;
# Line 490 | Line 504 | begin
504    Result := '';
505    with FItemData^ do
506    case FDataType of
507 +  dtIntegerFixed,
508    dtInteger:
509      Result := IntToStr(getAsInteger);
510    dtByte:
# Line 765 | Line 780 | var i, j: integer;
780   begin
781    for i := 0 to length(FItems) - 1 do
782    begin
783 <    for j := 0 to Length(FItems[i]^.FSubItems) -1 do
784 <      dispose(FItems[i]^.FSubItems[j]);
785 <    dispose(FItems[i]);
783 >    if FItems[i] <> nil then
784 >    begin
785 >      for j := 0 to Length(FItems[i]^.FSubItems) -1 do
786 >        if FItems[i]^.FSubItems[j] <> nil then
787 >          dispose(FItems[i]^.FSubItems[j]);
788 >      dispose(FItems[i]);
789 >    end;
790    end;
791    FreeMem(FBuffer);
792    inherited Destroy;
# Line 843 | Line 862 | begin
862      else
863        begin
864          item := TOutputBlockItem.Create(self,(aItems[i]));
865 <        writeln(Indent,'ItemType = ',byte(FBufPtr^),' Value = ',(item as TOutputBlockItem).GetAsString);
865 >        try
866 >          writeln(Indent,'ItemType = ',byte(FBufPtr^),' Value = ',(item as TOutputBlockItem).GetAsString);
867 >        except
868 >          writeln(Indent,'Unknown ItemType = ',byte(FBufPtr^));
869 >        end;
870        end;
871      end;
872    end;
# Line 860 | Line 883 | begin
883      if byte(FBuffer[i]) = isc_info_end then break;
884    end;
885    writeln;
886 +  for i := 0 to getBufSize - 1 do
887 +  begin
888 +    if chr(FBuffer[i]) in [' '..'~'] then
889 +      write(chr(Buffer[i]))
890 +    else
891 +      write('.');
892 +    if byte(FBuffer[i]) = isc_info_end then break;
893 +  end;
894 +  writeln;
895   end;
896  
897   { TDBInfoItem }
# Line 1062 | Line 1094 | begin
1094      while (P < FBufPtr + FSize) and (P^ <> isc_info_flag_end) do
1095      begin
1096        SetLength(FSubItems,i+1);
1097 +      FSubItems[i] := nil;
1098        case group of
1099        isc_info_svc_svr_db_info:
1100          case integer(P^) of
# Line 1073 | Line 1106 | begin
1106              FSubItems[i] := AddStringItem(P);
1107  
1108            else
1109 <            IBError(ibxeOutputParsingError, [integer(P^)]);
1109 >            IBError(ibxeOutputParsingError, [integer(P^),BufToStr(P,FSize - (P-FBufPtr))]);
1110            end;
1111  
1112        isc_info_svc_get_license:
# Line 1082 | Line 1115 | begin
1115          isc_spb_lic_key:
1116            FSubItems[i] := AddIntegerItem(P);
1117          else
1118 <          IBError(ibxeOutputParsingError, [integer(P^)]);
1118 >          IBError(ibxeOutputParsingError, [integer(P^),BufToStr(P,FSize - (P-FBufPtr))]);
1119          end;
1120  
1121        isc_info_svc_limbo_trans:
# Line 1101 | Line 1134 | begin
1134         isc_spb_tra_state:
1135           FSubItems[i] := AddByteItem(P);
1136         else
1137 <         IBError(ibxeOutputParsingError, [integer(P^)]);
1137 >         IBError(ibxeOutputParsingError, [integer(P^),BufToStr(P,FSize - (P-FBufPtr))]);
1138         end;
1139  
1140        isc_info_svc_get_users:
# Line 1119 | Line 1152 | begin
1152            FSubItems[i] := AddStringItem(P);
1153  
1154          else
1155 <          IBError(ibxeOutputParsingError, [integer(P^)]);
1155 >          IBError(ibxeOutputParsingError, [integer(P^),BufToStr(P,FSize - (P-FBufPtr))]);
1156          end;
1157  
1158        end;
# Line 1170 | Line 1203 | begin
1203    while  (P < Buffer + getBufSize) and (P^ <> isc_info_end) do
1204    begin
1205      SetLength(FItems,i+1);
1206 +    FItems[i] := nil;
1207      case integer(P^) of
1208      isc_info_svc_line,
1209      isc_info_svc_get_env,
# Line 1204 | Line 1238 | begin
1238  
1239  
1240      else
1241 <       IBError(ibxeOutputParsingError, [integer(P^)]);
1241 >       IBError(ibxeOutputParsingError, [integer(P^),BufToStr(P,getBufSize - (P-Buffer))]);
1242      end;
1243      P := P + FItems[i]^.FSize;
1244      Inc(i);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines