From: <na...@us...> - 2010-07-12 11:25:49
|
Revision: 898 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=898&view=rev Author: nandod Date: 2010-07-12 11:25:42 +0000 (Mon, 12 Jul 2010) Log Message: ----------- * Fixed AV when loading large files in blob attributes. Reversed wrong change made in #830. Modified Paths: -------------- trunk/Source/Core/InstantPersistence.pas Modified: trunk/Source/Core/InstantPersistence.pas =================================================================== --- trunk/Source/Core/InstantPersistence.pas 2010-04-18 05:35:40 UTC (rev 897) +++ trunk/Source/Core/InstantPersistence.pas 2010-07-12 11:25:42 UTC (rev 898) @@ -3645,7 +3645,6 @@ function TInstantBlob.Write(const Buffer; Position, Count: Integer): Integer; var LValue: AnsiString; - LBufferPointer: {$IFDEF D12+}PByte{$ELSE}PChar{$ENDIF}; function CompareBuffers: Boolean; var @@ -3653,7 +3652,7 @@ B: {$IFDEF D12+}Byte{$ELSE}Char{$ENDIF}; begin Stream.Position := Position; - for I := Position to Pred(Position + Count) do + for I := 0 to Pred(Count) do begin Result := (Stream.Read(B, 1) = 1) and (B = {$IFDEF D12+}PByte{$ELSE}PChar{$ENDIF}(@Buffer)[I]); if not Result then @@ -3663,11 +3662,10 @@ end; begin - SetLength(LValue, Count); - LBufferPointer := @Buffer; - Inc(LBufferPointer, Position); - StrLCopy(PAnsiChar(LValue), PAnsiChar(LBufferPointer), Count); + SetLength(LValue, Count + 1); + StrLCopy(PAnsiChar(LValue), PAnsiChar(@Buffer), Count); Validate(string(LValue)); + if not CompareBuffers then begin Stream.Position := Position; |