cainteoir: store the document on the stack instead of using a shared_ptr