Menu

#103 Function::Evaluate doesn't handle native closures correctly when SCRAT_NO_ERROR_CHECKING is undefined

None
closed
nobody
None
5
2020-11-09
2020-11-02
No

Function::Evaluate doesn't handle native closures correctly when SCRAT_NO_ERROR_CHECKING is undefined.

Line 241 of sqratFunction.h (no param version, but that doesn't seem to matter):
if (SQ_SUCCEEDED(sq_getclosureinfo(vm, -2, &nparams, &nfreevars)) && (nparams != 1)) {

This will fail every time because calling a native closure seems to always return 0 for nparams, regardless of the number of params passed.

Not sure if that's a problem with Squirrel (in sq_getclosureinfo) or Sqrat.

Discussion

  • Wizzard

    Wizzard - 2020-11-06

    This is definitely an issue with Sqrat. You're not really supposed to call sq_getclosureinfo on a native closure. The most correct thing to do would be to ignore this check if it's a native closure. However, it might also suffice just to add a nparams != 0 check to all the Evaluate functions. I'll accept a pull request if you add the checks in and can verify it fixes the issue.

     
  • Wizzard

    Wizzard - 2020-11-06

    if (SQ_SUCCEEDED(sq_getclosureinfo(vm, -2, &nparams, &nfreevars)) && (nparams != 1) && (nparams != 0)) {

     
  • Wizzard

    Wizzard - 2020-11-09
    • status: open --> closed
    • Group: -->
     

Log in to post a comment.

MongoDB Logo MongoDB