diff --git a/core/src/html/layout.rs b/core/src/html/layout.rs
index 649c70c61..02e25b763 100644
--- a/core/src/html/layout.rs
+++ b/core/src/html/layout.rs
@@ -93,6 +93,10 @@ impl<'a, 'gc> LayoutContext<'a, 'gc> {
/// Apply all indents and alignment to the current line, if necessary.
fn fixup_line(&mut self, mc: MutationContext<'gc, '_>) {
+ if self.current_line.is_none() {
+ return;
+ }
+
let mut line = self.current_line;
let mut line_bounds = None;
while let Some(linebox) = line {