Skip to content

Commit

Permalink
Raise errors for a 0-length fixed array (e.g. int[0])
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Jul 20, 2016
1 parent ab07ecf commit 537a29c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function parseTypeNxM (type) {
function parseTypeArray (type) {
var tmp = /^\w+\[(\d*)\]$/.exec(type)[1]
if (tmp.length === 0) {
return 0
return -1
} else {
return parseInt(tmp, 10)
}
Expand Down Expand Up @@ -119,7 +119,7 @@ function encodeSingle (type, arg) {
}

size = parseTypeArray(type)
if ((size !== 0) && (arg.length > size)) {
if ((size >= 0) && (arg.length > size)) {
throw new Error('Elements exceed array size: ' + size)
}

Expand Down

0 comments on commit 537a29c

Please sign in to comment.