b: fix creation of shared_ptr to be exception-safe