Skip to content

dead code after return generating incorrect code #1039

@mattdimeo

Description

@mattdimeo

Dead code after a return statement can cause the dead code to be executed and its value returned.

The following (stupid) code:

async function xyzzy(a,b)
{
    if ( a) {
        return await foo(a) ;
        console.log(a) ;
    } else {
        return await bar(b) ;
        console.log(b) ;
    }
}

Generates:

async function xyzzy(_0x4d572d,_0x223eb9){return _0x4d572d?(await foo(_0x4d572d),console['log'](a)):(await bar(_0x223eb9),console['log'](b));}

Which incorrectly executes the console.log and returns the wrong value.

Expected Behavior

Probably shouldn't allow the comma-substitution thing after a return statement.

Steps to Reproduce

Obfuscate the above code using --output $TMP_OBF_DIR --compact true --disable-console-output false --string-array-rotate true --self-defending true --string-array false --unicode-escape-sequence false

Your Environment

  • Obfuscator version used: 3.0.0
  • Node version used: v16.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions