js-confuser icon indicating copy to clipboard operation
js-confuser copied to clipboard

Control Flow Flattening breaks function declaration in non-executed switch case block

Open MichaelXF opened this issue 2 years ago • 0 comments

Config and Small code sample

Config:

{
  target: "node",
  controlFlowFlattening: true
}

Code:

switch (true) {
  case false:
    function myFunction() { // This block is never ran, but declaration is still able to be called
      console.log("Hello World!");
    }
    break;

  case true:
    myFunction();
    break;
}

var filler1;
var filler2;
// "Hello World"

Expected behavior

The program should output "Hello World"

Actual behavior

TypeError: (intermediate value)(intermediate value) is not a function

MichaelXF avatar Jun 06 '23 05:06 MichaelXF