Skip to content

Rest arguement is mishandled when controlFlowFlattening is enabled #920

Closed

Description

@zeeker999

Expected Behavior

Expected output:

function f(e, h, i, j) {
    console['log'](e, h, i, j);
}
function g(...b) {
    const c = {
        'vtpEA': function (d, ...e) {
            return d(...e);
        }
    };
    c['vtpEA'](f, ...b, 0x5);
}
const a = [
    0x1,
    0x2,
    0x3
];
g(...a, 0x4);

Current Behavior

Current output:

function f(e, h, i, j) {
    console['log'](e, h, i, j);
}
function g(...b) {
    const c = {
        'vtpEA': function (d, ...e, h) {
            return d(...e, h);
        }
    };
    c['vtpEA'](f, ...b, 0x5);
}
const a = [
    0x1,
    0x2,
    0x3
];
g(...a, 0x4);

Your Environment

  • Obfuscator version used: 2.12.0
  • Node version used: 14.10.1

Stack trace

Minimal working example that will help to reproduce issue

function f(a, b, c, d) {
  console.log(a, b, c, d)
}

function g(...args) {
  f(...args, 5)
}
const a = [1, 2, 3]
g(...a, 4)

Activity

  1. sanex3339 commented on May 23, 2021

    @sanex3339
    Member

    Hi. Will try to fix it today.

  2. sanex3339 commented on May 23, 2021

    @sanex3339
    Member

    So, seems we can always suppose that if we have a rest argument in the start/middle of call arguments then in the function parameters this argument will always be used as the last parameter.

    function bar(a, b, ...args) { // rest always as the last argument
        foo(a, b, ...args, 7)
    }
                
    bar(1, 2, ...[3, 4, 5], 6); // rest at the start or middle
    
  3. sanex3339 commented on May 23, 2021

    @sanex3339
    Member

    PR:
    #921

  4. sanex3339 commented on May 23, 2021

    @sanex3339
    Member

    Released as 2.13.0, please try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions