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:
parent
1fe74d9d98
commit
49122f7d6c
@ -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 */
|
||||
|
17
db/json.cpp
17
db/json.cpp
@ -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 ) {
|
||||
|
Loading…
Reference in New Issue
Block a user