Properly wrap a returned `char *` that could be `nullptr` into an `std::optional<std::string>`. `std::string` doesn't like `nullptr`. Another problem was that the wrapped `char *` was actually allocated on the heap, and not freed after conversion to a `std::string`, causing memory leaks.