Json Lexer - ParsedJsonDataSet

Discussion to talk about software related topics only.
seulater
Posts: 445
Joined: Fri Apr 25, 2008 5:26 am

Re: Json Lexer - ParsedJsonDataSet

Post by seulater »

The number in PrintObjectTobuffer is the MAX size that it is allowed to use.
So we start with:
char packJSON[1000];
you then do memset..
memset(packJSON,'\n',sizeof(packJSON));
you fill the 1000 bytes with \n....

what will strlen(packJSON) return?
strlen starts at the beginning of packJSON and moves forward till it finds a null.
we filled All of packJSON with \n so strlen won't find a 0 there...
it will walk off the end of packJSON into other memory looking for the null...
it may never find one...in which case it will eventually trap.....
what were 100% sure of is it won't return 1000....>
I agree and with all this, but doesn't this: "JsonOutObject.PrintObjectToBuffer(packJSON, sizeof(packJSON));" fill the buffer beyond the actual string that was packed?
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Json Lexer - ParsedJsonDataSet

Post by pbreed »

No it just puts the JSON in the buffer and stops with a null.
It does not fill the buffer
Post Reply