aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-09-04 13:22:59 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-09-04 13:22:59 +1200
commit977af04a174a6b8af06309427477d5ddd9e9d583 (patch)
treeec9747e34bd5b95ea21226045fea587dcb5f602a /src/org
parent65e0cec500c23b6d49ebf0c2950c205076de1177 (diff)
downloadtraccar-server-977af04a174a6b8af06309427477d5ddd9e9d583.tar.gz
traccar-server-977af04a174a6b8af06309427477d5ddd9e9d583.tar.bz2
traccar-server-977af04a174a6b8af06309427477d5ddd9e9d583.zip
Fix buffer search utility
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/helper/BufferUtil.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/org/traccar/helper/BufferUtil.java b/src/org/traccar/helper/BufferUtil.java
index 5606dba8a..15c619ec5 100644
--- a/src/org/traccar/helper/BufferUtil.java
+++ b/src/org/traccar/helper/BufferUtil.java
@@ -37,10 +37,11 @@ public final class BufferUtil {
}
public static int indexOf(String needle, ByteBuf haystack, int startIndex, int endIndex) {
- haystack = Unpooled.wrappedBuffer(haystack);
- haystack.readerIndex(startIndex);
- haystack.writerIndex(endIndex);
- return indexOf(needle, haystack);
+ ByteBuf wrappedHaystack = Unpooled.wrappedBuffer(haystack);
+ wrappedHaystack.readerIndex(startIndex - haystack.readerIndex());
+ wrappedHaystack.writerIndex(endIndex - haystack.readerIndex());
+ int result = indexOf(needle, wrappedHaystack);
+ return result < 0 ? result : haystack.readerIndex() + result;
}
}