Skip to content

Commit 82208af

Browse files
committed
Fixed data out of bounds error bug.
Fixed data out of bounds error bug.
1 parent eaac2b4 commit 82208af

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* NodeJS QRCode generator. Can save image or svg to file, get standard base64 image data url text or get SVG serialized text. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.(Running without DOM on server side)
55
*
6-
* Version 4.3.1
6+
* Version 4.3.2
77
*
88
* @author [ [email protected] ]
99
*
@@ -1024,7 +1024,7 @@ function _getTypeNumber(sText, _htOption) {
10241024
var nType = 1;
10251025
var length = _getUTF8Length(sText);
10261026

1027-
for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
1027+
for (var i = 0, len = QRCodeLimitLength.length; i < len; i++) {
10281028
var nLimit = 0;
10291029

10301030
switch (nCorrectLevel) {
@@ -1049,7 +1049,8 @@ function _getTypeNumber(sText, _htOption) {
10491049
}
10501050
}
10511051
if (nType > QRCodeLimitLength.length) {
1052-
throw new Error("Too long data");
1052+
throw new Error("Too long data. the CorrectLevel." + ['M', 'L', 'H', 'Q'][nCorrectLevel] +
1053+
" limit length is " + nLimit);
10531054
}
10541055

10551056
if (_htOption.version != 0) {
@@ -1107,11 +1108,11 @@ Drawing.prototype.draw = function(oQRCode) {
11071108
var nCount = oQRCode.getModuleCount();
11081109
var nWidth = Math.round(_htOption.width / nCount);
11091110
var nHeight = Math.round((_htOption.height - _htOption.titleHeight) / nCount);
1110-
if(nWidth<=1){
1111-
nWidth=1;
1111+
if (nWidth <= 1) {
1112+
nWidth = 1;
11121113
}
1113-
if(nHeight<=1){
1114-
nHeight=1;
1114+
if (nHeight <= 1) {
1115+
nHeight = 1;
11151116
}
11161117

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

0 commit comments

Comments
 (0)