summaryrefslogtreecommitdiff
path: root/bson
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2011-09-01 20:01:57 -0400
committerMathias Stearn <mathias@10gen.com>2011-09-01 20:29:22 -0400
commit4d8cd672bb03d466130ba8a48b828e03bb72b3cf (patch)
treee242a424398a277a0c5b4146c51e88b4549137d4 /bson
parentcee4f0ef879d2ec3307957c0e203140f226f9ef8 (diff)
downloadmongo-4d8cd672bb03d466130ba8a48b828e03bb72b3cf.tar.gz
Don't try to backfill more than 1.5M array elements SERVER-3750
Diffstat (limited to 'bson')
-rw-r--r--bson/bsonobjbuilder.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/bson/bsonobjbuilder.h b/bson/bsonobjbuilder.h
index f61d45879f3..86a52ac0cde 100644
--- a/bson/bsonobjbuilder.h
+++ b/bson/bsonobjbuilder.h
@@ -24,6 +24,7 @@
#include <limits>
#include <cmath>
+#include <boost/static_assert.hpp>
#include "bsonelement.h"
#include "bsonobj.h"
#include "bsonmisc.h"
@@ -764,6 +765,11 @@ namespace mongo {
}
void fill (int upTo){
+ // if this is changed make sure to update error message and jstests/set7.js
+ const int maxElems = 1500000;
+ BOOST_STATIC_ASSERT(maxElems < (BSONObjMaxUserSize/10));
+ uassert(15891, "can't backfill array to larger than 1,500,000 elements", upTo <= maxElems);
+
while( _i < upTo )
append( nullElt() );
}