aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-11-08 16:19:28 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-11-08 16:19:28 -0800
commit5b3ee0a9666a9c7fe3b3c04d1fe637b7d7b935da (patch)
treea2436d0de4a92cd18a7aeffcaa363cfe4e0815a8 /src/main/java/org/traccar/protocol
parent9f8505ebf73bba5e329fc5467fe00e43f989fd0d (diff)
downloadtraccar-server-5b3ee0a9666a9c7fe3b3c04d1fe637b7d7b935da.tar.gz
traccar-server-5b3ee0a9666a9c7fe3b3c04d1fe637b7d7b935da.tar.bz2
traccar-server-5b3ee0a9666a9c7fe3b3c04d1fe637b7d7b935da.zip
Handle empty serial messages
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
index 80e84c156..98f74ac84 100644
--- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -1229,7 +1229,10 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // external device type code
int length = buf.readableBytes() - 9; // line break + checksum + index + checksum + footer
- if (length < 8) {
+
+ if (length <= 0) {
+ return null;
+ } else if (length < 8) {
position.set(
Position.PREFIX_TEMP + 1,
Double.parseDouble(buf.readCharSequence(length - 1, StandardCharsets.US_ASCII).toString()));