From 07cc85ccb15c648d197a5570e088c163fb52c3d9 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 2 Oct 2025 02:37:16 -0700 Subject: [PATCH] Default initialize before swap in move constructor Fix #9373, fix #9384, fix #9400, fix #9404 --- native/src/base/files.hpp | 1 + native/src/base/misc.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/native/src/base/files.hpp b/native/src/base/files.hpp index cf223f033..29c84ea64 100644 --- a/native/src/base/files.hpp +++ b/native/src/base/files.hpp @@ -13,6 +13,7 @@ struct mmap_data : public byte_data { (sizeof(void *) == 4 && BLKGETSIZE64 == 0x80041272)); ALLOW_MOVE_ONLY(mmap_data) + mmap_data() = default; explicit mmap_data(const char *name, bool rw = false); mmap_data(int dirfd, const char *name, bool rw = false); mmap_data(int fd, size_t sz, bool rw = false); diff --git a/native/src/base/misc.hpp b/native/src/base/misc.hpp index 7645c7f24..1e11d5da0 100644 --- a/native/src/base/misc.hpp +++ b/native/src/base/misc.hpp @@ -15,7 +15,7 @@ clazz(clazz &&) = delete; #define ALLOW_MOVE_ONLY(clazz) \ clazz(const clazz&) = delete; \ -clazz(clazz &&o) { swap(o); } \ +clazz(clazz &&o) : clazz() { swap(o); } \ clazz& operator=(clazz &&o) { swap(o); return *this; } struct Utf8CStr;