renan-guimaraes / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Bug is ParseJSONString if the string to be read is longer than 50 characters #309

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Parse some JSON string where that string is longer than 50 characters 

What is the expected output? What do you see instead?
The string would be parsed and returned as a JSON string.

What version of the product are you using? On what operating system?
2.2

Please provide any additional information below.
The bug is at the bottom of the ParseJSONString function.  When longer than 50 
chars a TWriteOnlyBlockStream is used, but when the string is "built" at the 
end of the function the remaining portion is written over the start of the 
resultant string.

My fix is:

      if wobs<>nil then begin
         nw:=(wobs.Size div SizeOf(WideChar));
         SetLength(Result, n+nw);
         wobs.StoreData(Result[1]);
         if n>0 then
            Move(localBuffer[0], Result[nw+1], n*SizeOf(WideChar));
      end else begin
         SetLength(Result, n);
         if n>0 then
            Move(localBuffer[0], Result[1], n*SizeOf(WideChar));
      end;

Original issue reported on code.google.com by tony.mur...@gmail.com on 18 Nov 2012 at 4:56

GoogleCodeExporter commented 9 years ago
This should already be fixed in the SVN and in the 2.3 preview.

(the 2.3 should be more stable than 2.2, due to more unit tests)

Original comment by zar...@gmail.com on 19 Nov 2012 at 8:08