]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
parser: use stoul(), not strtol()
authorJustin Viiret <justin.viiret@intel.com>
Thu, 2 Feb 2017 04:01:30 +0000 (15:01 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 26 Apr 2017 04:57:53 +0000 (14:57 +1000)
src/parser/Parser.rl

index 9cddace4216036e10351ad991af5a8ba8108b02b..913eaa0e065369fbe5683ec3cd3153fbcfac1c8f 100644 (file)
@@ -974,7 +974,7 @@ unichar readUtf8CodePoint4c(const char *s) {
 
               '\\o{' [0-7]+ '}' => {
                   string oct(ts + 3, te - ts - 4);
-                  long int val = strtol(oct.c_str(), nullptr, 8);
+                  unsigned long val = stoul(oct, nullptr, 8);
                   if ((!mode.utf8 && val > 255) || val > MAX_UNICODE) {
                       throw LocatedParseError("Value in \\o{...} sequence is too large");
                   }
@@ -999,7 +999,7 @@ unichar readUtf8CodePoint4c(const char *s) {
               # Unicode Hex
               '\\x{' xdigit+ '}' => {
                   string hex(ts + 3, te - ts - 4);
-                  long int val = strtol(hex.c_str(), nullptr, 16);
+                  unsigned long val = stoul(hex, nullptr, 16);
                   if (val > MAX_UNICODE) {
                       throw LocatedParseError("Value in \\x{...} sequence is too large");
                   }
@@ -1488,7 +1488,7 @@ unichar readUtf8CodePoint4c(const char *s) {
               };
               '\\o{' [0-7]+ '}' => {
                   string oct(ts + 3, te - ts - 4);
-                  long int val = strtol(oct.c_str(), nullptr, 8);
+                  unsigned long val = stoul(oct, nullptr, 8);
                   if ((!mode.utf8 && val > 255) || val > MAX_UNICODE) {
                       throw LocatedParseError("Value in \\o{...} sequence is too large");
                   }
@@ -1505,7 +1505,7 @@ unichar readUtf8CodePoint4c(const char *s) {
               # Unicode Hex
               '\\x{' xdigit+ '}' => {
                   string hex(ts + 3, te - ts - 4);
-                  long int val = strtol(hex.c_str(), nullptr, 16);
+                  unsigned long val = stoul(hex, nullptr, 16);
                   if (val > MAX_UNICODE) {
                       throw LocatedParseError("Value in \\x{...} sequence is too large");
                   }