Commit 8d2b1cb
committed
AVRO-4298: [php] Reject negative union branch index
schemaByIndex validated only the upper bound (count > index), so a negative
index passed the check and then indexed $schemas[-1] => null, violating the
AvroSchema return type with a TypeError instead of a clean AvroException. Add a
lower-bound check (index >= 0) so a negative branch index is rejected with
AvroSchemaParseException. Adds tests for negative and too-large union indices.
(readEnum is already guarded via array_key_exists.)
Assisted-by: GitHub Copilot:claude-opus-4.81 parent 0d02b5b commit 8d2b1cb
2 files changed
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
319 | 337 | | |
320 | 338 | | |
321 | 339 | | |
| |||
0 commit comments