Browse Source

* fix ShortString handling in TValue (always the maximum length of the corresponding ShortString type is allocated)

git-svn-id: trunk@40694 -
svenbarth 6 years ago
parent
commit
2c20643ba6
1 changed files with 2 additions and 5 deletions
  1. 2 5
      packages/rtl-objpas/src/inc/rtti.pp

+ 2 - 5
packages/rtl-objpas/src/inc/rtti.pp

@@ -1609,11 +1609,8 @@ begin
   { first handle those types that need a TValueData implementation }
   { first handle those types that need a TValueData implementation }
   case ATypeInfo^.Kind of
   case ATypeInfo^.Kind of
     tkSString  : begin
     tkSString  : begin
-                   if Assigned(ABuffer) then
-                     size := Length(PShortString(ABuffer)^) + 1
-                   else
-                     size := 256;
-                   result.FData.FValueData := TValueDataIntImpl.CreateCopy(ABuffer, size, ATypeInfo, True);
+                   td := GetTypeData(ATypeInfo);
+                   result.FData.FValueData := TValueDataIntImpl.CreateCopy(ABuffer, td^.MaxLength + 1, ATypeInfo, True);
                  end;
                  end;
     tkWString,
     tkWString,
     tkUString,
     tkUString,