It's always properly initialized in the derived classes so far,
but let's make sure it stays that way.
Also make sure we don't call mdb_cursor_close() on a nullptr
cursor after being moved.
Reported by Coverity (CID
1401632).
return d_cursor;
}
- MDB_cursor* d_cursor;
+ MDB_cursor* d_cursor{nullptr};
Transaction* d_parent;
};
MDBROCursor(MDBROCursor&& rhs) : MDBGenCursor<MDBROTransaction>(rhs.d_parent)
{
d_cursor = rhs.d_cursor;
- rhs.d_cursor=0;
+ rhs.d_cursor = nullptr;
}
void close()
{
- mdb_cursor_close(d_cursor);
- d_cursor=0;
+ if (d_cursor) {
+ mdb_cursor_close(d_cursor);
+ d_cursor = nullptr;
+ }
}
~MDBROCursor()
MDBRWCursor(MDBRWCursor&& rhs) : MDBGenCursor<MDBRWTransaction>(rhs.d_parent)
{
d_cursor = rhs.d_cursor;
- rhs.d_cursor=0;
+ rhs.d_cursor = nullptr;
d_parent->reportCursorMove(&rhs, this);
}
{
if(d_cursor)
mdb_cursor_close(d_cursor);
- d_cursor=0;
+ d_cursor = nullptr;
}
~MDBRWCursor()