#1 2013-04-24 10:35:44

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 93

JSONTOOBJECT with string property length >= 257 -> access violation

Hi, Delphi2009ent


We have a working TCollection item from TInterfacedCollection. (it worked with previous version of mOrmot).


  TremotePLC = class(TCollectionItem)
  published
    // server itemhandle
    property lokacija:string read flokacija write flokacija;
    property IP:string read fIP write fIP;
    property Connected:Boolean read fConnected write fConnected;
    property ErrStr:string read fErrStr write fErrStr;
    property numPersecs:Integer read fnumPersecs write fnumPersecs;
    property dbblokov:Integer read fdbblokov write fdbblokov;
    property dbblocksstrs:string read fdbblocksstrs write fdbblocksstrs;

  { Description:
      db;tagname;connectionstr;value;quality;active;sessiontime }
    property tagsstr:string read ftagsstr write ftagsstr;  // if this is longer than 257 -> access violation
  end;

to reproduce:

var
  I: Integer;
  ljsonstr: RawUTF8;
begin
  aPLCStatuess:= TremotePLCs.Create;
  plc := aPLCStatuess.Add;
  plc.tagsstr := '';
  for J := 0 to 257 do plc.tagsstr := plc.tagsstr +'_';
  ljsonstr := ObjectToJSON(aPLCStatuess);
  JSONToObject(aPLCStatuess,PUTF8Char(ljsonstr),lvalid); ==> access violation

if we use widestring it's ok.

thank you, vojko

Last edited by VojkoCendak (2013-04-24 10:38:04)

Offline

#2 2013-04-24 12:27:44

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: JSONTOOBJECT with string property length >= 257 -> access violation

I was able to reproduce the issue with Delphi XE3 (no problem with non Unicode version of Delphi).

We have replaced unexpected use of Utf8ToUnicodeString() into correct SynCommons value.
See http://synopse.info/fossil/info/f67ad3556e

It will fix such potential GPF in JSONToObject() when unserializing UnicodeString properties.

Thanks a lot for the report, even if the code to reproduce the problem was truncated.
smile

Offline

#3 2013-04-24 15:30:26

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 93

Re: JSONTOOBJECT with string property length >= 257 -> access violation

It's working now. Thank you.

Offline

Board footer

Powered by FluxBB