mongodb/mongo-c-driver — pull request #161 by jsbattig (2013-11-27 22:45:58+00:00)
Title: Fixed access violation when killing primary replica during heaving cursor reading

When using a capped collection to read heavily objects inserted at fast pace, the modified operation of destoying the reply buffer on the cursor ends up generating a dangling pointer that finished in an access violation the next time that bson_free( cursor->reply ) is called.

The code I post here fixed the issue, but maybe we should consider adding a little static function to manage the reply field on the cursor object.

Something like:

```
static void cursor_deleteReply( cursor _this )
{
bson_free( _this->reply );
_this->reply = NULL;
}
```

We should also call that function from the cursor destructor method.