Commit 1b5e6f8
committed
fix(pgtype): return error instead of panicking on malformed interval text
scanPlanTextAnyToIntervalScanner read timeParts[0][0] without checking that
the hours segment is non-empty. An interval text value whose time component
starts with a colon, such as ":05:06", splits into an empty hours segment and
panics with "index out of range [0] with length 0".
Guard the byte access so an empty hours segment falls through to
strconv.ParseInt, which already returns a "bad interval hour format" error.
This matches the malformed-text handling added for the geometric types.1 parent 7fd58a7 commit 1b5e6f8
2 files changed
Lines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
| 235 | + | |
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments