diff options
| author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-10-17 10:33:50 -0700 | 
|---|---|---|
| committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-10-17 10:33:50 -0700 | 
| commit | 0e09571f21d41969a26e9ec73ef0da78d9371d38 (patch) | |
| tree | f4e921109fc05c4595f92e835a3c3ab3488a0868 /src | |
| parent | e8e54ea5de080d33780c68847057adf82c12ec16 (diff) | |
Fix integer overflow detection with leading zeros
Since they don't contribute to the resulting value just skip them before
parsing. This matches the behavior of strtol/strtoll and results in more
intuitive behavior.
Diffstat (limited to 'src')
| -rw-r--r-- | src/pugixml.cpp | 8 | 
1 files changed, 8 insertions, 0 deletions
| diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 694a1a6..9bb054e 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4350,6 +4350,10 @@ PUGI__NS_BEGIN  		{  			s += 2; +			// since overflow detection relies on length of the sequence skip leading zeros +			while (*s == '0') +				s++; +  			const char_t* start = s;  			for (;;) @@ -4370,6 +4374,10 @@ PUGI__NS_BEGIN  		}  		else  		{ +			// since overflow detection relies on length of the sequence skip leading zeros +			while (*s == '0') +				s++; +  			const char_t* start = s;  			for (;;) | 
