Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2747 Check for explicit case fallthru

caheckman45374b3354b4
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
index 5584dbf4d5..6110093336 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc
@@ -3425,6 +3425,11 @@ FlowBlock *BlockSwitch::nextFlowAfter(const FlowBlock *bl) const
{
if (getBlock(0) == bl)
return (FlowBlock *)0; // Don't know what will execute
+
+ // Can only evaluate this if bl is a case block that falls through to another case block.
+ // Otherwise there is a break statement in the flow
+ if (bl->getType() != t_goto) // Fallthru must be a goto block
+ return (FlowBlock *)0;
int4 i;
// Look for block to find flow after
for(i=0;i<caseblocks.size();++i)