TJSONParser.Create(TStream, TJSONOptions) does not respect the position of the stream
Original Reporter info from Mantis: BBaz @basile.b
-
Reporter name:
Original Reporter info from Mantis: BBaz @basile.b
- Reporter name:
Description:
This is a regression. Previously the stream passed as parameter was read from its current position, now it is fully loaded.
The problem is that the content going from 0 to Position() may contain data unrealted to JSON.
Steps to reproduce:
program Project1;
uses Classes, jsonparser;
var
s : TMemoryStream;
p : TJSONParser;
i : integer;
t : string = #01#02#03#04'{}';program Project1;
uses Classes, jsonparser;
var
s : TMemoryStream;
p : TJSONParser;
i : integer;
t : string = #01#02#03#04'{}';
begin
s := TMemoryStream.Create;
try
s.Write(t[1], length(t));
s.Position := 0;
s.Read(i, 4);
p := TJSONParser.Create(s);
try
p.Parse();
finally
p.Free;
end;
finally
s.Free;
end;
end.
begin
s := TMemoryStream.Create;
try
s.Write(t[1], length(t));
s.Position := 0;
s.Read(i, 4);
p := TJSONParser.Create(s);
try
p.Parse();
finally
p.Free;
end;
finally
s.Free;
end;
end.
Mantis conversion info:
- Mantis ID: 37332
- Version: 3.2.0
- Fixed in revision: 45776 (#515b9226)