mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
fix zero pointers in deleted lists on alloc()
This commit is contained in:
parent
0c1fd901af
commit
3d428ce459
45
db/jsobj.cpp
45
db/jsobj.cpp
@ -459,7 +459,30 @@ int JSMatcher::matchesDotted(const char *fieldName, Element& toMatch, JSObj& obj
|
||||
|
||||
extern int dump;
|
||||
|
||||
/* deep means we looked into arrays for a match */
|
||||
inline bool _regexMatches(RegexMatcher& rm, Element& e) {
|
||||
char buf[64];
|
||||
const char *p = buf;
|
||||
if( e.type() == String )
|
||||
p = e.valuestr();
|
||||
else if( e.type() == Number ) {
|
||||
sprintf(buf, "%f", e.number());
|
||||
}
|
||||
else if( e.type() == Date ) {
|
||||
unsigned long long d = e.date();
|
||||
time_t t = (d/1000);
|
||||
time_t_to_String(t, buf);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return rm.re->PartialMatch(p);
|
||||
}
|
||||
inline bool regexMatches(RegexMatcher& rm, Element& e) {
|
||||
return _regexMatches(rm, e);
|
||||
}
|
||||
|
||||
/* See if an object matches the query.
|
||||
deep - return true when meanswe looked into arrays for a match
|
||||
*/
|
||||
bool JSMatcher::matches(JSObj& jsobj, bool *deep) {
|
||||
if( deep )
|
||||
*deep = false;
|
||||
@ -472,24 +495,8 @@ bool JSMatcher::matches(JSObj& jsobj, bool *deep) {
|
||||
Element e = jsobj.getFieldDotted(rm.fieldName);
|
||||
if( e.eoo() )
|
||||
return false;
|
||||
{
|
||||
char buf[64];
|
||||
const char *p = buf;
|
||||
if( e.type() == String )
|
||||
p = e.valuestr();
|
||||
else if( e.type() == Number ) {
|
||||
sprintf(buf, "%f", e.number());
|
||||
}
|
||||
else if( e.type() == Date ) {
|
||||
unsigned long long d = e.date();
|
||||
time_t t = (d/1000);
|
||||
time_t_to_String(t, buf);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
if( !rm.re->PartialMatch(p) )
|
||||
return false;
|
||||
}
|
||||
if( !regexMatches(rm, e) )
|
||||
return false;
|
||||
}
|
||||
|
||||
// check normal non-regex cases:
|
||||
|
@ -132,8 +132,9 @@ DiskLoc NamespaceDetails::__stdAlloc(int len) {
|
||||
while( 1 ) {
|
||||
{
|
||||
int a = cur.a();
|
||||
if( a < -1 || a >= 100000 ) {
|
||||
problem() << "Assertion failure - a() out of range in _alloc() " << a << endl;
|
||||
if( a < -1 || a >= 100000 ) {
|
||||
problem() << "~~ Assertion - cur out of range in _alloc() " << cur.toString() <<
|
||||
" b:" << b << " chain:" << chain << '\n';
|
||||
sayDbContext();
|
||||
if( cur == *prev )
|
||||
prev->Null();
|
||||
@ -168,6 +169,11 @@ DiskLoc NamespaceDetails::__stdAlloc(int len) {
|
||||
cur.Null();
|
||||
}
|
||||
else {
|
||||
if( r->nextDeleted.getOfs() == 0 ) {
|
||||
problem() << "~~ Assertion - bad nextDeleted " << r->nextDeleted.toString() <<
|
||||
" b:" << b << " chain:" << chain << ", fixing.\n";
|
||||
r->nextDeleted.Null();
|
||||
}
|
||||
cur = r->nextDeleted; prev = &r->nextDeleted;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user