fix byte array truncation issue