Skip to content

Commit

Permalink
bugfix: isNotValid should return true if invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
filipjonckers committed Jan 7, 2022
1 parent 321cbf9 commit d5e07f7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/aero/t2s/modes/decoder/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ public static short[] getParity(short[] data) {
}

public static boolean isNotValid(short[] data) {
// fixes negative length bug where data is only 2 bytes (16bit Mode A/C replies, ACAS, ...)
// examples: *21D2; *0200; *0101; <- only the 2 bytes are in data variable
if(data.length < 3) {
return false; // fixes negative length bug where data is only 2 bytes (16bit Mode A/C replies, ACAS, ...)
return true;
}
short[] payload = Arrays.copyOfRange(data, 0, data.length - 3);
short[] parity = Arrays.copyOfRange(data, data.length - 3, data.length);
Expand Down

0 comments on commit d5e07f7

Please sign in to comment.