ruby/test/yarp/fuzzer_test.rb
Mike Dalessio ae7f907559 [ruby/yarp] fix: heredoc with incomplete escape at end of file
Previously this resulted in invalid memory access.

Found by the fuzzer.

ec4abd87f4
2023-08-30 18:27:51 +00:00

27 lines
879 B
Ruby

# frozen_string_literal: true
require_relative "test_helper"
# These tests are simply to exercise snippets found by the fuzzer that caused invalid memory access.
class FuzzerTest < Test::Unit::TestCase
class << self
def snippet(name, source)
test "fuzzer #{name}" do
YARP.dump(source)
end
end
end
snippet "incomplete global variable", "$"
snippet "incomplete symbol", ":"
snippet "incomplete escaped string", '"\\'
snippet "trailing comment", "1\n#\n"
snippet "trailing asterisk", "a *"
snippet "incomplete decimal number", "0d"
snippet "incomplete binary number", "0b"
snippet "incomplete octal number", "0o"
snippet "incomplete hex number", "0x"
snippet "incomplete escaped list", "%w[\\"
snippet "incomplete escaped regex", "/a\\"
snippet "unterminated heredoc with unterminated escape at end of file", "<<A\n\\"
end