diff --git a/CHANGELOG.md b/CHANGELOG.md
index dd927cf4..8eeeac75 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
     - Fixed bug in pointers to string data blocks.
     - Restrict padding blocks so they do not share instructions with code blocks.
     - Start a new block if we transition from padding to not padding
+      or from not padding to padding.
     - Change the type of several heuristics from "simple" to "proportional"
     - Additional heuristic: Simple string literals in literal pools
     - Additional heuristic: Function beginning pattern with push/adjust-sp as plausible instruction sequence
diff --git a/src/datalog/code_inference.dl b/src/datalog/code_inference.dl
index 4ead19e6..9eca74b6 100644
--- a/src/datalog/code_inference.dl
+++ b/src/datalog/code_inference.dl
@@ -384,7 +384,9 @@ block_limit(Inst):-
     arch.instruction_at(EA+Size,Inst).
 
 /**
-We want to split blocks that go from non-padding to padding.
+We want to split blocks that go from non-padding to padding
+or from padding to non-padding.
+
 However, this cannot be a regular block_limit because several
 instructions could fallthrough into another one.
 We need to consider the source address too.
@@ -396,6 +398,11 @@ transition_block_limit(EA,Next):-
     next(EA,Next),
     !is_padding(EA).
 
+transition_block_limit(EA,Next):-
+    is_padding(EA),
+    next(EA,Next),
+    !is_padding(Next).
+
 // The targets are computed incrementally now as we traverse the code
 // likely_ea and possible_target_from are mutually recursive