Skip to content
This repository has been archived by the owner on Feb 22, 2019. It is now read-only.

Commit

Permalink
Should handle illegal dimensions throw
Browse files Browse the repository at this point in the history
  • Loading branch information
benjohnde committed Nov 27, 2018
1 parent b3be35a commit e5326ed
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ZXingObjC/common/ZXHybridBinarizer.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import "ZXByteArray.h"
#import "ZXHybridBinarizer.h"
#import "ZXIntArray.h"
#import "ZXErrors.h"

// This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels.
// So this is the smallest dimension in each axis we can accept.
Expand Down Expand Up @@ -46,6 +47,11 @@ - (ZXBitMatrix *)blackMatrixWithError:(NSError **)error {
ZXLuminanceSource *source = [self luminanceSource];
int width = source.width;
int height = source.height;
if (width == 0 || height == 0) {
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"Source is empty"};
if (error) *error = [[NSError alloc] initWithDomain:ZXErrorDomain code:ZXNotFoundError userInfo:userInfo];
return nil;
}
if (width >= ZX_MINIMUM_DIMENSION && height >= ZX_MINIMUM_DIMENSION) {
ZXByteArray *luminances = source.matrix;
int subWidth = width >> ZX_BLOCK_SIZE_POWER;
Expand Down

0 comments on commit e5326ed

Please sign in to comment.