Skip to content

Commit

Permalink
Fix potential panic in parsing code
Browse files Browse the repository at this point in the history
  • Loading branch information
koesie10 committed May 26, 2024
1 parent 0d8c3ad commit f4dce43
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion smartmeter/smartmeter.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (sm *SmartMeter) parsePacket(datagram [][]byte) (*P1Packet, error) {
for i, line := range datagram {
dataStart := bytes.IndexRune(line, '(')
dataEnd := bytes.IndexRune(line, ')')
if dataStart < 0 || dataEnd < 0 {
if dataStart < 0 || dataEnd < 0 || dataEnd <= dataStart {
continue
}
identifier := string(line[:dataStart])
Expand Down

0 comments on commit f4dce43

Please sign in to comment.