Fixed nullptr check for std::unique_ptr in distributions to avoid calling garbage.