Skip to content

Commit 9656329

Browse files
jackcclaude
andcommitted
Simplify multirange header length check
rp is 0 at this point, so the re-slice in len(src[rp:]) was dead weight. Use len(src) directly and match the error message to the equivalent guard in array.go ("array header too short: %d"). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 20d88e8 commit 9656329

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pgtype/multirange.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,10 @@ func (c *MultirangeCodec) PlanScan(m *Map, oid uint32, format int16, target any)
207207
func (c *MultirangeCodec) decodeBinary(m *Map, multirangeOID uint32, src []byte, multirange MultirangeSetter) error {
208208
rp := 0
209209

210-
if len(src[rp:]) < 4 {
211-
return fmt.Errorf("multirange too short for element count: %d bytes", len(src[rp:]))
210+
if len(src) < 4 {
211+
return fmt.Errorf("multirange header too short: %d", len(src))
212212
}
213+
213214
elementCount := int(binary.BigEndian.Uint32(src[rp:]))
214215
rp += 4
215216

0 commit comments

Comments
 (0)