Explorar o código

* Fix bug #28818, patch from Alexey Torgashin

git-svn-id: trunk@32001 -
michael %!s(int64=9) %!d(string=hai) anos
pai
achega
e8a4b6c820
Modificáronse 1 ficheiros con 6 adicións e 15 borrados
  1. 6 15
      packages/fcl-json/src/jsonscanner.pp

+ 6 - 15
packages/fcl-json/src/jsonscanner.pp

@@ -353,9 +353,7 @@ begin
           end;
         end;
         SectionLength := TokenStr - TokenStart;
-        SetLength(FCurTokenString, SectionLength);
-        if SectionLength > 0 then
-          Move(TokenStart^, FCurTokenString[1], SectionLength);
+        SetString(FCurTokenString, TokenStart, SectionLength);
         If (FCurTokenString[1]='.') then
           FCurTokenString:='0'+FCurTokenString;
         Result := tkNumber;
@@ -393,9 +391,7 @@ begin
       Case Tokenstr[0] of
         '/' : begin
               SectionLength := Length(FCurLine)- (TokenStr - PChar(FCurLine));
-              SetLength(FCurTokenString,SectionLength);
-              if SectionLength > 0 then
-                Move(TokenStart^, FCurTokenString[1], SectionLength);
+              SetString(FCurTokenString, TokenStart, SectionLength);
               Fetchline;
               end;
         '*' :
@@ -407,9 +403,8 @@ begin
             if (TokenStr[0]=#0) then
               begin
               SectionLength := (TokenStr - TokenStart);
-              SetLength(S,SectionLength);
-              if SectionLength > 0 then
-                Move(TokenStart^, S[1], SectionLength);
+              SetString(S, TokenStart, SectionLength);
+
               FCurtokenString:=FCurtokenString+S;
               if not fetchLine then
                 Error(SUnterminatedComment, [CurRow,CurCOlumn,TokenStr[0]]);
@@ -422,9 +417,7 @@ begin
           if EOC then
             begin
             SectionLength := (TokenStr - TokenStart-1);
-            SetLength(S,SectionLength);
-            if SectionLength > 0 then
-              Move(TokenStart^, S[1], SectionLength);
+            SetString(S, TokenStart, SectionLength);
             FCurtokenString:=FCurtokenString+S;
             Inc(TokenStr);
             end;
@@ -441,9 +434,7 @@ begin
           Inc(TokenStr);
         until not (TokenStr[0] in ['A'..'Z', 'a'..'z', '0'..'9', '_']);
         SectionLength := TokenStr - TokenStart;
-        SetLength(FCurTokenString, SectionLength);
-        if SectionLength > 0 then
-          Move(TokenStart^, FCurTokenString[1], SectionLength);
+        SetString(FCurTokenString, TokenStart, SectionLength);
         for it := tkTrue to tkNull do
           if CompareText(CurTokenString, TokenInfos[it]) = 0 then
             begin