journeyapps / zxing-android-embedded

Barcode scanner library for Android, based on the ZXing decoder
https://journeyapps.com/
Apache License 2.0
5.76k stars 1.27k forks source link

java.lang.ArrayIndexOutOfBoundsException #209

Closed rczhang13028 closed 8 years ago

rczhang13028 commented 8 years ago

Description of the problem:

Sorry, My English is poor. Have a function is decodeContinuous of CompoundBarcodeView class. I use this function for scan qrcode. Sometimes crash。

Which library version are you using? E.g. 3.2.0. version 3.2.0 . zxing 3.2.1

Which phone/tablet are you using, and which Android version does it run? (e.g. Samsung Galaxy S5,Android 5.0) Xiaomi:Redmi Note 3:arm64-v8a, Android 5.0.2

Does the same happen on other devices or an emulator? Meizu:MX5:arm64-v8a,Android 5.1 Meizu:m3:arm64-v8a,Android 5.1
Xiaomi:Redmi Note 2:arm64-v8a,Android 5.0.2

Can you reproduce the issue in the sample project included with the library? If not, can you provide your own sample project or sample code that produces this error? i can not reproduce the issue.

In the case of an error do you have a stack trace or adb logs?

java.lang.ArrayIndexOutOfBoundsException: length=460800; index=920320 at com.journeyapps.barcodescanner.n.a(SourceData.java:185) at com.journeyapps.barcodescanner.n.a(SourceData.java:158) at com.journeyapps.barcodescanner.n.g(SourceData.java:97) at com.journeyapps.barcodescanner.i.a(DecoderThread.java:126) at com.journeyapps.barcodescanner.i.b(DecoderThread.java:134) at com.journeyapps.barcodescanner.i.a(DecoderThread.java:22) at com.journeyapps.barcodescanner.i$1.handleMessage(DecoderThread.java:38) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:192) at android.os.HandlerThread.run(HandlerThread.java:61)

rczhang13028 commented 8 years ago

thanks

rkistner commented 8 years ago

Thanks for the report, will look into it.

rczhang13028 commented 8 years ago

Excuse me ,How are you getting along with the work?

rkistner commented 8 years ago

Added potential fix in 42d09b810b36ee904bb54b73ae17aab819dd31ea.

The crash is from a mismatch between the expected preview resolution, and the size of the preview data received. I'm not sure what the exact cause is - could be a device-specific bug, or an edge case in the library.

If the mismatch is just with a single preview, this change should fix it. If the mismatch is persistent, there is a deeper issue, and scanning will fail (but at least it shouldn't crash anymore).

rczhang13028 commented 8 years ago

thanks