[vte] libc: glue: Make FD self-assignment safe
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] libc: glue: Make FD self-assignment safe
- Date: Wed, 27 May 2020 19:17:25 +0000 (UTC)
commit 197954648bf6868e63872d9d32339bd985d4a9ef
Author: Christian Persch <chpe src gnome org>
Date: Wed May 27 21:17:04 2020 +0200
libc: glue: Make FD self-assignment safe
src/libc-glue.hh | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/libc-glue.hh b/src/libc-glue.hh
index e42ebe16..941375c1 100644
--- a/src/libc-glue.hh
+++ b/src/libc-glue.hh
@@ -19,6 +19,7 @@
#include <cassert>
#include <cerrno>
+#include <memory>
#include <unistd.h>
#include <fcntl.h>
@@ -64,8 +65,10 @@ public:
FD& operator=(FD&& rhs) noexcept
{
- reset();
- m_fd = rhs.release();
+ if (this != std::addressof(rhs)) {
+ reset();
+ m_fd = rhs.release();
+ }
return *this;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]