Prevent --raw CLR option from failing if result.getRawBytes() is null (#1683)

Fixes https://github.com/zxing/zxing/issues/1682
This commit is contained in:
Dan Lenski 2023-09-06 18:58:06 -07:00 committed by GitHub
parent 557b5fcf0e
commit 672bd40958
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -168,14 +168,17 @@ final class DecodeWorker implements Callable<Integer> {
if (config.outputRaw) { if (config.outputRaw) {
StringBuilder rawData = new StringBuilder(); StringBuilder rawData = new StringBuilder();
byte[] rawBytes = result.getRawBytes();
for (byte b : result.getRawBytes()) { if (rawBytes != null) {
rawData.append(String.format("%02X", b & 0xff)); for (byte b : rawBytes) {
rawData.append(" "); rawData.append(String.format("%02X", b & 0xff));
rawData.append(" ");
}
rawData.setLength(rawData.length() - 1); // chop off final space
output.write("Raw bits:\n" + rawData + "\n");
} }
rawData.setLength(rawData.length() - 1); // chop off final space
output.write("Raw bits:\n" + rawData + "\n");
} }
ResultPoint[] resultPoints = result.getResultPoints(); ResultPoint[] resultPoints = result.getResultPoints();