Skip to content

Commit c3546b6

Browse files
committed
Fix out of bounds crash when using updated play services and firebase decoder module
1 parent f8a82d6 commit c3546b6

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.61.3]
5+
6+
### Fixed
7+
- Fixed out of bounds crash when using firebase decoder with updated play services
8+
49
## [0.61.2]
510

611
### Added

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ allprojects {
3131
}
3232

3333
project.ext {
34-
sdkVersion='0.61.2'
34+
sdkVersion='0.61.3'
3535
versionCode=1
3636

3737
compileSdkVersion=31

firebase-detector/src/main/java/io/snabble/sdk/firebase/FirebaseBarcodeDetector.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ public void reset() {
6565
public io.snabble.sdk.ui.scanner.Barcode detect(byte[] data, int width, int height, int bitsPerPixel, Rect detectionRect, int displayOrientation) {
6666
byte[] buf = crop(data, width, height, bitsPerPixel, detectionRect);
6767

68-
InputImage inputImage = InputImage.fromByteArray(buf, width, height, displayOrientation, InputImage.IMAGE_FORMAT_NV21);
68+
InputImage inputImage = InputImage.fromByteArray(buf,
69+
detectionRect.width(),
70+
detectionRect.height(),
71+
displayOrientation,
72+
InputImage.IMAGE_FORMAT_NV21);
6973

7074
Task<List<Barcode>> result = detector.process(inputImage);
7175

@@ -125,7 +129,7 @@ public io.snabble.sdk.ui.scanner.Barcode detect(byte[] data, int width, int heig
125129
}
126130

127131
private byte[] crop(byte[] data, int width, int height, int bitsPerPixel, Rect detectionRect) {
128-
int size = detectionRect.width() * detectionRect.height() * bitsPerPixel / 8;
132+
int size = detectionRect.width() * detectionRect.height() * bitsPerPixel / 8 * 3;
129133
if (cropBuffer == null || cropBuffer.length != size) {
130134
cropBuffer = new byte[size];
131135
}

0 commit comments

Comments
 (0)