summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-10-21 15:32:43 +0200
committerHiroshi SHIBATA <[email protected]>2024-10-26 18:44:15 +0900
commit70f554efb468278d4488c988f1eb59d00bacbda5 (patch)
tree0f47761505b56a549d8a40c1e5c32d16879836f8 /test
parent00aa1f9a1d9ea2c7fc99bd9063174f0247f3df08 (diff)
[ruby/json] raise_parse_error: avoid UB
Fix: https://github.com/ruby/json/pull/625 Declaring the buffer in a sub block cause bugs on some compilers. https://github.com/ruby/json/commit/90967c9eb0
Diffstat (limited to 'test')
-rw-r--r--test/json/json_parser_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/json/json_parser_test.rb b/test/json/json_parser_test.rb
index e4300e94fd..8d3c0c17c5 100644
--- a/test/json/json_parser_test.rb
+++ b/test/json/json_parser_test.rb
@@ -514,6 +514,15 @@ EOT
assert_operator 60, :>, error.message.bytesize
end
+ def test_parse_error_incomplete_hash
+ error = assert_raise(JSON::ParserError) do
+ JSON.parse('{"input":{"firstName":"Bob","lastName":"Mob","email":"[email protected]"}')
+ end
+ if RUBY_ENGINE == "ruby" && defined?(JSON::Ext)
+ assert_equal %(unexpected token at '{"input":{"firstName":"Bob","las'), error.message
+ end
+ end
+
private
def string_deduplication_available?