strdup() may fail

master
Volker Birk 2022-05-22 16:20:42 +02:00
parent 46539695c0
commit cf9205d621
1 changed files with 3 additions and 1 deletions

View File

@ -49,9 +49,11 @@ namespace SignedPackage {
{
std::filesystem::path path = std::filesystem::temp_directory_path() / "spXXXXXXXXXXXX";
std::unique_ptr< char[] > buffer { ::strdup(path.c_str()) };
if (!buffer.get())
throw std::bad_alloc();
char *p = mkdtemp(buffer.get());
if (p == nullptr) {
if (!p) {
throw std::filesystem::filesystem_error(::strerror(errno),
std::error_code(errno, std::system_category()));
}