Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException on files with only 1 pixel #607

Closed
AbdealiLoKo opened this issue Jun 10, 2016 · 3 comments
Closed

ArrayIndexOutOfBoundsException on files with only 1 pixel #607

AbdealiLoKo opened this issue Jun 10, 2016 · 3 comments
Assignees
Labels
Milestone

Comments

@AbdealiLoKo
Copy link

When running on a file like https://commons.wikimedia.org/wiki/File:Pix.gif which has only 1 pixel, zxing throws an error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    at com.google.zxing.common.GlobalHistogramBinarizer.getBlackRow(GlobalHistogramBinarizer.java:71)
    at com.google.zxing.BinaryBitmap.getBlackRow(BinaryBitmap.java:66)
    at com.google.zxing.oned.OneDReader.doDecode(OneDReader.java:132)
    at com.google.zxing.oned.OneDReader.decode(OneDReader.java:54)
    at com.google.zxing.MultiFormatReader.decodeInternal(MultiFormatReader.java:171)
    at com.google.zxing.MultiFormatReader.decode(MultiFormatReader.java:69)
    at com.google.zxing.multi.GenericMultipleBarcodeReader.doDecodeMultiple(GenericMultipleBarcodeReader.java:84)
    at com.google.zxing.multi.GenericMultipleBarcodeReader.decodeMultiple(GenericMultipleBarcodeReader.java:65)
    at com.google.zxing.client.j2se.DecodeWorker.decode(DecodeWorker.java:140)
    at com.google.zxing.client.j2se.DecodeWorker.call(DecodeWorker.java:75)
    at com.google.zxing.client.j2se.CommandLineRunner.main(CommandLineRunner.java:84)

Obviously barcodes will never exist in files that have 1 pixel, but zxing should not crash for it. (I'm running it on a lot of files, and this happened to be one of them)

The issue is that localLuminance in GlobalHistogramBinarizer directly accesses the 2nd element (which does not exist).

@AbdealiLoKo
Copy link
Author

AbdealiLoKo commented Jun 10, 2016

Also, I opened this issue as documentation mainly, as I don't plan to provide a PR for it anytime soon :)
You can close it (as per your policy).

@srowen
Copy link
Contributor

srowen commented Jun 10, 2016

No problem, this one is so trivial that I can easily reproduce and fix, so I'll just do it.

@srowen srowen added the bug label Jun 10, 2016
@srowen srowen self-assigned this Jun 10, 2016
@srowen srowen added this to the 3.2.2 milestone Jun 10, 2016
@AbdealiLoKo
Copy link
Author

:D Awesome thanks ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants