Test that ObjectEach doesn't panic with out-of-bounds access after removing the `offset < len(data)` loop guard. Verifies: SYS-REQ-007 [boundary]
(t *testing.T)
| 9 | |
| 10 | // Verifies: SYS-REQ-007 [boundary] |
| 11 | func TestObjectEach_OOB_TruncatedAfterComma(t *testing.T) { |
| 12 | // {"a":1, — truncated right after comma, no more data |
| 13 | // After parsing "a":1, finds comma at step 4, increments offset past comma. |
| 14 | // Then step "skip to next token after comma" calls nextToken on remaining data. |
| 15 | // If remaining is empty → nextToken returns -1 → returns MalformedArrayError. |
| 16 | // No panic. |
| 17 | err := ObjectEach([]byte(`{"a":1,`), func(key []byte, value []byte, dataType ValueType, offset int) error { |
| 18 | return nil |
| 19 | }) |
| 20 | if err == nil { |
| 21 | t.Fatal("expected error for truncated object after comma") |
| 22 | } |
| 23 | t.Logf("Correctly got error: %v", err) |
| 24 | } |
| 25 | |
| 26 | // Verifies: SYS-REQ-007 [boundary] |
| 27 | func TestObjectEach_OOB_TruncatedAfterColon(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…