Skip to content

Commit

Permalink
Fix OOM when parsing bare hex number.
Browse files Browse the repository at this point in the history
Fixes #228.
  • Loading branch information
mkantor authored and jordanbtucker committed Apr 4, 2020
1 parent 661c418 commit f1d3c8a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/util.js
Expand Up @@ -2,11 +2,11 @@ const unicode = require('../lib/unicode')

module.exports = {
isSpaceSeparator (c) {
return unicode.Space_Separator.test(c)
return typeof c === 'string' && unicode.Space_Separator.test(c)
},

isIdStartChar (c) {
return (
return typeof c === 'string' && (
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c === '$') || (c === '_') ||
Expand All @@ -15,7 +15,7 @@ module.exports = {
},

isIdContinueChar (c) {
return (
return typeof c === 'string' && (
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') ||
Expand All @@ -26,10 +26,10 @@ module.exports = {
},

isDigit (c) {
return /[0-9]/.test(c)
return typeof c === 'string' && /[0-9]/.test(c)
},

isHexDigit (c) {
return /[0-9A-Fa-f]/.test(c)
return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
},
}

0 comments on commit f1d3c8a

Please sign in to comment.