Content-Length: 270472 | pFad | https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1039

84 dead code after return generating incorrect code · Issue #1039 · javascript-obfuscator/javascript-obfuscator · GitHub
Skip to content

dead code after return generating incorrect code #1039

Closed
@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









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/javascript-obfuscator/javascript-obfuscator/issues/1039

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy