summaryrefslogtreecommitdiffstats
path: root/base/string_number_conversions.cc
diff options
context:
space:
mode:
authorali.akbar@gmail.com <ali.akbar@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-12 20:13:20 +0000
committerali.akbar@gmail.com <ali.akbar@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-12 20:13:20 +0000
commit331580b5a604f073f4afabd21537d42de3732178 (patch)
tree3b373d59c475851b9a1d849275e24da3e2f5db8b /base/string_number_conversions.cc
parentd81f2286f59f740262ec02d4d4f6d3ea29216cfd (diff)
downloadchromium_src-331580b5a604f073f4afabd21537d42de3732178.zip
chromium_src-331580b5a604f073f4afabd21537d42de3732178.tar.gz
chromium_src-331580b5a604f073f4afabd21537d42de3732178.tar.bz2
Fixes a corner case bug in the HexStringToInt conversion function which caused the string "0x" to be treated as a valid hexadecimal number.
Although the parsed result was 0, the boolean flag returned indicated that the hex number was in proper format The IteratorRangeToNumber class's Invoke function increments the string pointer by 2 if the string starts with "0x" or "0X" and the length is greater than *or equal* to 2 If the length of the string is 2, i.e "0x", after the pointer increment, the string would be empty and the function returns true as the parse result Changed the condition from "greater than or equal to" to "greater than" Added another test cases which now properly treats "0x" as an invalid hex string Contributed by ali.akbar@gmail.com BUG=92054 Review URL: http://codereview.chromium.org/7584031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_number_conversions.cc')
-rw-r--r--base/string_number_conversions.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/base/string_number_conversions.cc b/base/string_number_conversions.cc
index c700467..54eca17 100644
--- a/base/string_number_conversions.cc
+++ b/base/string_number_conversions.cc
@@ -220,7 +220,7 @@ class IteratorRangeToNumber {
// Note: no performance difference was found when using template
// specialization to remove this check in bases other than 16
- if (traits::kBase == 16 && end - begin >= 2 && *begin == '0' &&
+ if (traits::kBase == 16 && end - begin > 2 && *begin == '0' &&
(*(begin + 1) == 'x' || *(begin + 1) == 'X')) {
begin += 2;
}