b8524a
t a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb
b8524a
index e6e0b41..da17cd5 100644
b8524a
--- a/lib/rdoc/ruby_lex.rb
b8524a
+++ b/lib/rdoc/ruby_lex.rb
b8524a
@@ -1028,6 +1028,8 @@ def identify_here_document
b8524a
     end
b8524a
 
b8524a
     if output_heredoc then
b8524a
+      raise Error, "Missing terminating #{quoted} for string" unless l
b8524a
+
b8524a
       doc << l.chomp
b8524a
     else
b8524a
       doc << '"'
b8524a
diff --git a/test/rdoc/test_rdoc_ruby_lex.rb b/test/rdoc/test_rdoc_ruby_lex.rb
b8524a
index 0dcb425..56ddf60 100644
b8524a
--- a/test/rdoc/test_rdoc_ruby_lex.rb
b8524a
+++ b/test/rdoc/test_rdoc_ruby_lex.rb
b8524a
@@ -162,6 +162,18 @@ def test_class_tokenize_heredoc_indent
b8524a
     assert_equal expected, tokens
b8524a
   end
b8524a
 
b8524a
+  def test_class_tokenize_heredoc_missing_end
b8524a
+    e = assert_raises RDoc::RubyLex::Error do
b8524a
+      RDoc::RubyLex.tokenize <<-'RUBY', nil
b8524a
+>> string1 = <<-TXT
b8524a
+>" That's swell
b8524a
+>" TXT
b8524a
+      RUBY
b8524a
+    end
b8524a
+
b8524a
+    assert_equal 'Missing terminating TXT for string', e.message
b8524a
+  end
b8524a
+
b8524a
   def test_class_tokenize_heredoc_percent_N
b8524a
     tokens = RDoc::RubyLex.tokenize <<-'RUBY', nil
b8524a
 a b <<-U
b8524a
-- 
b8524a
1.8.4