Skip to content

transformObjectKeys breaks code with arrow function #813

@sxzz

Description

@sxzz

Expected Behavior

output: Hello

Current Behavior

VM118:3 Uncaught TypeError: Cannot read property 'name' of null
    at <anonymous>:3:25

Steps to Reproduce

  1. https://obfuscator.io/

Your Environment

  • Obfuscator version used: 2.9.1
  • Node version used: v14.15.0

Stack trace

VM118:3 Uncaught TypeError: Cannot read property 'name' of null
    at <anonymous>:3:25

Minimal working example that will help to reproduce issue

let info = null;
const test = () => ({
  name: info.name,
});
info = { name: "Hello" };

console.log(test().name);

Code after obfuscation

let info = null;
const _0x1ed649 = {};
_0x1ed649['name'] = info['name'];
const test = () => _0x1ed649;
const _0x5d0656 = {};
_0x5d0656['name'] = 'Hello';
info = _0x5d0656;
console['log'](test()['name']);

The code of the arrow function should not be moved outside, but normal functions will not cause this problem.

let info = null;
const test = function () {
  return {
    name: info.name,
  };
};
info = { name: "Hello" };
console.log(test().name);

// after obfuscation
let info = null;
const test = function () {
    const _0xce0ef3 = {};
    _0xce0ef3['name'] = info['name'];
    return _0xce0ef3;
};
const _0x4a2275 = {};
_0x4a2275['name'] = 'Hello';
info = _0x4a2275;
console['log'](test()['name']);

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