The main posixpp library and associated tests.
修订版 | 9eb80934ba7d3ad70bd3c8d8b9df6de3813effde (tree) |
---|---|
时间 | 2021-05-11 01:07:00 |
作者 | Eric Hopper <hopper@omni...> |
Commiter | Eric Hopper |
Fix 'move to self' bug.
@@ -35,11 +35,12 @@ | ||
35 | 35 | //! looks valid, and it will ignore the return value. |
36 | 36 | fd &operator =(fd &&other) noexcept { |
37 | 37 | using ::syscalls::linux::close; |
38 | + int const tmpfd = other.fd_; | |
39 | + other.fd_ = -1; | |
38 | 40 | if (fd_ >= 0) { |
39 | 41 | close(fd_); // Ignore any error return. |
40 | 42 | } |
41 | - fd_ = other.fd_; | |
42 | - other.fd_ = -1; | |
43 | + fd_ = tmpfd; | |
43 | 44 | return *this; |
44 | 45 | } |
45 | 46 |