renan-guimaraes / dwscript

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

Infinite loop - stack overflow in RTTI #396

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Unit DWSRTTIExposer.pas, method:

class function TdwsRTTIInvoker.ValueFromIInfo(asType : TRttiType; const info : 
IInfo) : TValue;
[...]
begin
   case asType.TypeKind of
      tkInteger, tkInt64 :
         Result:=TValue.From<Int64>(info.ValueAsInteger);
      tkFloat :
         Result:=TValue.From<Double>(info.ValueAsFloat);
      tkChar, tkString, tkUString, tkWChar, tkLString, tkWString :
         Result:=TValue.From<String>(info.ValueAsString);
      tkVariant :
         Result:=TValue.From<Variant>(info.Value);
      tkRecord :
         Result:=ValueFromRecord(asType, info);
      tkEnumeration :
         if asType.Handle=TypeInfo(Boolean) then
            Result:=info.ValueAsBoolean
         else Result:=info.ValueAsInteger;
      tkDynArray: begin
       [...]
      end
   else
      Result:=ValueFromIInfo(asType, info);//<-- infinite loop with tkMethod
      Result:=TValue.Empty;
      Assert(False);
   end;
end;

If executing enter to this method with asType.TypeKind = tkMethod it starts an 
recursion loop and finally cause stack overflow.

Original issue reported on code.google.com by jac....@gmail.com on 15 May 2013 at 9:19

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2109.

Original comment by zar...@gmail.com on 17 May 2013 at 9:46