File tree 1 file changed +3
-27
lines changed 1 file changed +3
-27
lines changed Original file line number Diff line number Diff line change @@ -597,33 +597,9 @@ bool Reader::decodeDouble(Token& token) {
597
597
598
598
bool Reader::decodeDouble (Token& token, Value& decoded) {
599
599
double value = 0 ;
600
- const int bufferSize = 32 ;
601
- int count;
602
- int length = int (token.end_ - token.start_ );
603
-
604
- // Sanity check to avoid buffer overflow exploits.
605
- if (length < 0 ) {
606
- return addError (" Unable to parse token length" , token);
607
- }
608
-
609
- // Avoid using a string constant for the format control string given to
610
- // sscanf, as this can cause hard to debug crashes on OS X. See here for more
611
- // info:
612
- //
613
- // http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html
614
- char format[] = " %lf" ;
615
-
616
- if (length <= bufferSize) {
617
- Char buffer[bufferSize + 1 ];
618
- memcpy (buffer, token.start_ , length);
619
- buffer[length] = 0 ;
620
- count = sscanf (buffer, format, &value);
621
- } else {
622
- std::string buffer (token.start_ , token.end_ );
623
- count = sscanf (buffer.c_str (), format, &value);
624
- }
625
-
626
- if (count != 1 )
600
+ std::string buffer (token.start_ , token.end_ );
601
+ std::istringstream is (buffer);
602
+ if (!(is >> value))
627
603
return addError (" '" + std::string (token.start_ , token.end_ ) +
628
604
" ' is not a number." ,
629
605
token);
You can’t perform that action at this time.
0 commit comments