nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: apple/swift-protobuf
Pull request #1165 (2021-09-07 16:30:39)

Handle skipping an object that ends after the open brace.
- Add a test case.
- Include a case found via local fuzzing.


Patch:
diff --git a/Sources/SwiftProtobuf/JSONScanner.swift b/Sources/SwiftProtobuf/JSONScanner.swift
index f7094f60..d5e81720 100644
--- a/Sources/SwiftProtobuf/JSONScanner.swift
+++ b/Sources/SwiftProtobuf/JSONScanner.swift
@@ -1493,6 +1493,9 @@ internal struct JSONScanner {
   // they don't know; newer clients may reject the same input due to
   // schema mismatches or other issues.
   private mutating func skipString() throws {
+    guard hasMoreContent else {
+      throw JSONDecodingError.truncated
+    }
     if currentByte != asciiDoubleQuote {
       throw JSONDecodingError.malformedString
     }


Test patch:
diff --git a/FuzzTesting/FailCases/JSON-Any b/FuzzTesting/FailCases/JSON-Any
new file mode 100644
index 00000000..1ffb3f17
--- /dev/null
+++ b/FuzzTesting/FailCases/JSON-Any
@@ -0,0 +1,1 @@
+ {"wktAny":{"ny":{
\ No newline at end of file
diff --git a/Tests/SwiftProtobufTests/Test_FuzzTests.swift b/Tests/SwiftProtobufTests/Test_FuzzTests.swift
index 03fb6284..9f441f58 100644
--- a/Tests/SwiftProtobufTests/Test_FuzzTests.swift
+++ b/Tests/SwiftProtobufTests/Test_FuzzTests.swift
@@ -93,6 +93,9 @@ class Test_FuzzTests: XCTestCase {
     // FailCases/clusterfuzz-testcase-minimized-FuzzJSON_debug-4506617283477504
     // FailCases/clusterfuzz-testcase-minimized-FuzzJSON_release-5689942715006976
     assertJSONFails("{\"[fuzz.testing.singular_sint32_ext]\":null")
+
+    // FailCases/JSON-Any
+    assertJSONFails(" {\"wktAny\":{\"ny\":{")
   }
 
   func test_TextFormat() {