Skip to content

Commit b8c59de

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#899 from pkesseli/tempfile-avoid-unnecessary-unlink
Avoid unlink call on empty string
2 parents d4e8149 + ea526d0 commit b8c59de

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/util/tempfile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,6 @@ Function: temporary_filet::~temporary_filet
164164

165165
temporary_filet::~temporary_filet()
166166
{
167-
unlink(name.c_str());
167+
if(!name.empty())
168+
unlink(name.c_str());
168169
}

src/util/tempfile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class temporary_filet
3232
// Using the copy constructor would delete the file twice.
3333
temporary_filet(const temporary_filet &)=delete;
3434

35-
temporary_filet(temporary_filet &&other) :
36-
name(std::move(other.name))
35+
temporary_filet(temporary_filet &&other)
3736
{
37+
name.swap(other.name);
3838
}
3939

4040
// get the name

0 commit comments

Comments
 (0)