Skip to content

Commit c1ce2bd

Browse files
committed
fixes negative length bug - fixes #12
1 parent 48c031a commit c1ce2bd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/aero/t2s/modes/decoder/Common.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ public static short[] getParity(short[] data) {
106106
}
107107

108108
public static boolean isNotValid(short[] data) {
109+
if(data.length < 3) {
110+
return false; // fixes negative length bug where data is only 2 bytes (16bit Mode A/C replies, ACAS, ...)
111+
}
109112
short[] payload = Arrays.copyOfRange(data, 0, data.length - 3);
110113
short[] parity = Arrays.copyOfRange(data, data.length - 3, data.length);
111114

0 commit comments

Comments
 (0)