diff --git a/0.3.8/src/treebuilder/in_row.c b/0.3.8/src/treebuilder/in_row.c
index 3bf9161..43b9dac 100644
--- a/0.3.8/src/treebuilder/in_row.c
+++ b/0.3.8/src/treebuilder/in_row.c
@@ -57,10 +57,12 @@ static hubbub_error act_as_if_end_tag_tr(hubbub_treebuilder *treebuilder)
 
 	table_clear_stack(treebuilder);
 
-	element_stack_pop(treebuilder, &ns, &otype, &node);
+	if (current_node(treebuilder) != HTML) {
+		element_stack_pop(treebuilder, &ns, &otype, &node);
 
-	treebuilder->tree_handler->unref_node(treebuilder->tree_handler->ctx,
-			node);
+		treebuilder->tree_handler->unref_node(
+				treebuilder->tree_handler->ctx,	node);
+	}
 
 	treebuilder->context.mode = IN_TABLE_BODY;
 
