Overloaded code snippet (invalid code) crashes

Issue #89 resolved
Christian Budde created an issue

The following code is invalid as the "procedure cwd;" in the example should be a function that returns a string. However, the code below doesn't generate a proper error message, but causes a crash.

Again, it's not critical, but just to mention it.

type
  JConsole = class external 'Console'
  public
    procedure log(data: Variant); overload;
    procedure log(const data: array of const); overload;
  end;

type
  JNodeProcess = class external
    procedure cwd;
  end;

var
  Console external 'console': JConsole;

var
  Process external 'process': JNodeProcess;

Console.Log(process.cwd);

Comments (2)

  1. Christian Budde reporter

    Sorry, forgot the call stack:

    dwsSymbols.TOpenArraySymbol.IsCompatible(nil) dwsCompiler.TdwsCompiler.ResolveOverload($765B0BB0,$7668D350,((19, 13, $7668AAB0)),nil,[]) dwsCompiler.TdwsCompiler.WrapUpFunctionRead($765B0BB0,nil,$7668D350,[]) dwsCompiler.TdwsCompiler.ReadMethod($7677A0D0,$7668A970,(19, 9, $7668AAB0),nil,$7668D350) dwsCompiler.TdwsCompiler.ReadMethOverloaded($7677A0D0,$7668A970,(19, 9, $7668AAB0),nil) dwsCompiler.TdwsCompiler.ReadSymbolMemberExpr($7668A970,True,nil) dwsCompiler.TdwsCompiler.ReadSymbol($7668A970,True,nil) dwsCompiler.TdwsCompiler.ReadImplicitCall($7668A970,True,nil) dwsCompiler.TdwsCompiler.ReadDataSymbolName($768B9D10,$76BC3830,True,nil) dwsCompiler.TdwsCompiler.ReadName(True,nil)

    It crashes obviously because TypSym equals nil. A simple check should properly handle this case.

    Something like:

       [...]
       if not Assigned(TypSym) then
          Exit(False);
       [...]
    
  2. Log in to comment