Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Violation if closing bracket is missing on an object #111

Open
Boberoo opened this issue Mar 6, 2017 · 0 comments
Open

Access Violation if closing bracket is missing on an object #111

Boberoo opened this issue Mar 6, 2017 · 0 comments

Comments

@Boberoo
Copy link

Boberoo commented Mar 6, 2017

Major problem.

If I create a SuperObject, and pass in JSON that has a missing closing bracket, I get a nasty access violation instead of a nice friendly error message.

For example, use JSON like this:

{
"name" : "Fred" ,
"surname" : "Jones"

Instead of:

{
"name" : "Fred" ,
"surname" : "Jones"
}

The following fix seems to work nicely:

procedure TJSONBuilder.ReadObject(var Val: IJSONAncestor);
var
Name: String;
begin
LGen.KillLex;
Val := TJSONObject.Create;
repeat
if LGen.CheckName(Name) then
begin
LGen.KillLex;
if not LGen.CheckKill(ltColon) then
raise TJSONSyntaxError.CreateFmt(Err_Expected, [':'], LGen.Current.Pos);
TJSONObject(Val).AddPair(TJSONPair.Create(Name, ReadValue));
end
until not LGen.CheckKill(ltVirgule);

if not LGen.CheckKill(ltBRight) then
if LGen.Current = nil then //<<<<<<new
raise TJSONSyntaxError.Create(Err_UnexpectedEndOfInput, LGen.FCurrPos) //<<<<<<new
else
raise TJSONSyntaxError.Create(Err_UnexpectedEndOfInput, LGen.Current.Pos);
end;

onryldz added a commit that referenced this issue Aug 23, 2017
Fixed issue #111
Fixed issue #110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant