You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by tm...@apache.org on 2019/02/20 18:53:12 UTC

[incubator-plc4x] branch develop updated: - fixed NPE when reading odd-length array of one-byte base types

This is an automated email from the ASF dual-hosted git repository.

tmitsch pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 06a7c56  - fixed NPE when reading odd-length array of one-byte base types
06a7c56 is described below

commit 06a7c5617f16c4c30983861aedfb6324aeb59501
Author: Tim Mitsch <ti...@tmbeng.com>
AuthorDate: Wed Feb 20 19:53:08 2019 +0100

    - fixed NPE when reading odd-length array of one-byte base types
---
 .../s7/src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java
index 787b200..b3b5a87 100644
--- a/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java
+++ b/plc4j/protocols/s7/src/main/java/org/apache/plc4x/java/s7/netty/S7Protocol.java
@@ -619,8 +619,8 @@ public class S7Protocol extends ChannelDuplexHandler {
                 payloadItems.add(payload);
                 i += S7SizeHelper.getPayloadLength(payload);
 
-                // It seems that one-byte payloads require a fill byte, but only if it's not the last item.
-                if((length == 1) && (userData.readableBytes() > 0)) {
+                // It seems that odd-byte payloads require a fill byte, but only if it's not the last item.
+                if((length % 2== 1) && (userData.readableBytes() > 0)) {
                     userData.readByte();
                     i++;
                 }