NativeXml icon indicating copy to clipboard operation
NativeXml copied to clipboard

Range-Error in sdStreams.pas when Element.text is greater than 32k

Open MicrotronX opened this issue 1 year ago • 2 comments

Hi, there is a problem within the function tsdBufferWriter.write:

A tByteArray is used for the WriteChunk call but the tByteArray has a limit of 32k. In my case, I have disabled the ChunkWrites:

function TsdBufferWriter.Write(const Buffer; Count: Integer): Longint; var Idx, Siz: integer; begin // index in the source buffer Idx := 0; // remaining size Siz := Count;

fSource.WriteBuffer(Buffer, Count); // write everything at once

{ // code starting from here makes problems with big content! // surplus while FRawPosition + Siz >= FChunkSize do begin Move(TByteArray(Buffer)[Idx], FRawBuffer[FRawPosition], FChunkSize - FRawPosition); WriteChunk(FChunkSize); dec(Siz, FChunkSize - FRawPosition); inc(Idx, FChunkSize - FRawPosition); FRawPosition := 0; end;

// copy the raw buffer Move(TByteArray(Buffer)[Idx], FRawBuffer[FRawPosition], Siz); }

inc(FRawPosition, Siz);

Result := Count; end;

MicrotronX avatar Nov 17 '23 13:11 MicrotronX

Changed all :integer declarations in the unit to :longint and the problem is gone so far.

MicrotronX avatar Nov 24 '23 15:11 MicrotronX

Changed all :integer declarations in the unit to :longint and the problem is gone so far.

But LongInt is equal to Integer under Windows, are you sure that fixed the problem?

myonlylonely avatar Feb 08 '24 16:02 myonlylonely