0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

fix json parser cleanup

This commit is contained in:
Eliot Horowitz 2010-06-12 23:28:38 -04:00
parent 1fe74d9d98
commit 49122f7d6c
2 changed files with 17 additions and 3 deletions

View File

@ -53,8 +53,9 @@ namespace mongo {
}
~BSONObjBuilder(){
if ( _b.buf() && _buf.getSize() == 0 )
if ( !_doneCalled && _b.buf() && _buf.getSize() == 0 ){
_done();
}
}
/** add all the fields from the object specified to this object */

View File

@ -42,7 +42,18 @@ using namespace boost::spirit;
namespace mongo {
struct ObjectBuilder {
struct ObjectBuilder : boost::noncopyable {
~ObjectBuilder(){
unsigned i = builders.size();
if ( i ){
i--;
for ( ; i>=1; i-- ){
if ( builders[i] ){
builders[i]->done();
}
}
}
}
BSONObjBuilder *back() {
return builders.back().get();
}
@ -560,7 +571,9 @@ public:
ss << "Failure parsing JSON string near: " << string( result.stop, len );
massert( 10340 , ss.str(), false );
}
return b.pop();
BSONObj ret = b.pop();
assert( b.empty() );
return ret;
}
BSONObj fromjson( const string &str ) {