File tree Expand file tree Collapse file tree 1 file changed +3
-27
lines changed Expand file tree Collapse file tree 1 file changed +3
-27
lines changed Original file line number Diff line number Diff line change @@ -557,33 +557,9 @@ bool Reader::decodeDouble(Token& token) {
557
557
558
558
bool Reader::decodeDouble (Token& token, Value& decoded) {
559
559
double value = 0 ;
560
- const int bufferSize = 32 ;
561
- int count;
562
- int length = int (token.end_ - token.start_ );
563
-
564
- // Sanity check to avoid buffer overflow exploits.
565
- if (length < 0 ) {
566
- return addError (" Unable to parse token length" , token);
567
- }
568
-
569
- // Avoid using a string constant for the format control string given to
570
- // sscanf, as this can cause hard to debug crashes on OS X. See here for more
571
- // info:
572
- //
573
- // http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html
574
- char format[] = " %lf" ;
575
-
576
- if (length <= bufferSize) {
577
- Char buffer[bufferSize + 1 ];
578
- memcpy (buffer, token.start_ , length);
579
- buffer[length] = 0 ;
580
- count = sscanf (buffer, format, &value);
581
- } else {
582
- std::string buffer (token.start_ , token.end_ );
583
- count = sscanf (buffer.c_str (), format, &value);
584
- }
585
-
586
- if (count != 1 )
560
+ std::string buffer (token.start_ , token.end_ );
561
+ std::istringstream is (buffer);
562
+ if (!(is >> value))
587
563
return addError (" '" + std::string (token.start_ , token.end_ ) +
588
564
" ' is not a number." ,
589
565
token);
You can’t perform that action at this time.
0 commit comments