Skip to content

Commit a7c77a5

Browse files
committed
Fixed data out of bounds error bug.
Fixed data out of bounds error bug.
1 parent 6635b2e commit a7c77a5

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

QRCode.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* React Native QRCode generation component. Can generate standard QRCode image or base64 image data url text. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.
55
*
6-
* Version 4.0.1
6+
* Version 4.0.2
77
*
88
* @author [ [email protected] ]
99
*
@@ -1004,7 +1004,7 @@ function _getTypeNumber(sText, _htOption) {
10041004
var nType = 1;
10051005
var length = _getUTF8Length(sText);
10061006

1007-
for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
1007+
for (var i = 0, len = QRCodeLimitLength.length; i < len; i++) {
10081008
var nLimit = 0;
10091009

10101010
switch (nCorrectLevel) {
@@ -1029,7 +1029,8 @@ function _getTypeNumber(sText, _htOption) {
10291029
}
10301030
}
10311031
if (nType > QRCodeLimitLength.length) {
1032-
throw new Error("Too long data");
1032+
throw new Error("Too long data. the CorrectLevel." + ['M', 'L', 'H', 'Q'][nCorrectLevel] +
1033+
" limit length is " + nLimit);
10331034
}
10341035

10351036
if (_htOption.version != 0) {
@@ -1083,11 +1084,11 @@ Drawing.prototype.draw = function(oQRCode) {
10831084
var nCount = oQRCode.getModuleCount();
10841085
var nWidth = Math.round(_htOption.width / nCount);
10851086
var nHeight = Math.round((_htOption.height - _htOption.titleHeight) / nCount);
1086-
if(nWidth<=1){
1087-
nWidth=1;
1087+
if (nWidth <= 1) {
1088+
nWidth = 1;
10881089
}
1089-
if(nHeight<=1){
1090-
nHeight=1;
1090+
if (nHeight <= 1) {
1091+
nHeight = 1;
10911092
}
10921093

10931094
_htOption.quietZone = Math.round(_htOption.quietZone);

0 commit comments

Comments
 (0)