summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2010-07-15 14:16:47 -0400
committerMathias Stearn <mathias@10gen.com>2010-07-15 14:17:33 -0400
commitc5d33d557eeec1f9b1c48564e2a455cb7b227358 (patch)
treed276928bd2075ebc95e03cf738979fb44b2f69ba /client
parentb9600a1e9fa30c5de513ff9be9f7bc59395f5843 (diff)
downloadmongo-c5d33d557eeec1f9b1c48564e2a455cb7b227358.tar.gz
Assert if DBClientCursor is NULL SERVER-1372
Diffstat (limited to 'client')
-rw-r--r--client/dbclientcursor.cpp5
-rw-r--r--client/dbclientcursor.h8
2 files changed, 11 insertions, 2 deletions
diff --git a/client/dbclientcursor.cpp b/client/dbclientcursor.cpp
index f97919862cd..9fe40f97a70 100644
--- a/client/dbclientcursor.cpp
+++ b/client/dbclientcursor.cpp
@@ -130,6 +130,8 @@ namespace mongo {
/** If true, safe to call next(). Requests more from server if necessary. */
bool DBClientCursor::more() {
+ _assertIfNull();
+
if ( !_putBack.empty() )
return true;
@@ -200,6 +202,9 @@ namespace mongo {
}
DBClientCursor::~DBClientCursor() {
+ if (!this)
+ return;
+
DESTRUCTOR_GUARD (
if ( cursorId && _ownCursor ) {
diff --git a/client/dbclientcursor.h b/client/dbclientcursor.h
index 84f9cc6cc35..8f941400fe8 100644
--- a/client/dbclientcursor.h
+++ b/client/dbclientcursor.h
@@ -38,7 +38,7 @@ namespace mongo {
if you want to exhaust whatever data has been fetched to the client already but
then perhaps stop.
*/
- bool moreInCurrentBatch() { return !_putBack.empty() || pos < nReturned; }
+ bool moreInCurrentBatch() { _assertIfNull(); return !_putBack.empty() || pos < nReturned; }
/** next
@return next object in the result cursor.
@@ -90,7 +90,7 @@ namespace mongo {
available from the dbclientcursor.
*/
bool isDead() const {
- return cursorId == 0;
+ return !this || cursorId == 0;
}
bool tailable() const {
@@ -102,6 +102,7 @@ namespace mongo {
ResultFlag_ErrSet is the possible exception to that
*/
bool hasResultFlag( int flag ){
+ _assertIfNull();
return (resultFlags & flag) != 0;
}
@@ -176,6 +177,9 @@ namespace mongo {
void exhaustReceiveMore(); // for exhaust
bool _ownCursor; // see decouple()
string _scopedHost;
+
+ // Don't call from a virtual function
+ void _assertIfNull() { uassert(13348, "connection died", this); }
};