Default initialize before swap in move constructor

Fix #9373, fix #9384, fix #9400, fix #9404
This commit is contained in:
topjohnwu
2025-10-02 02:37:16 -07:00
committed by John Wu
parent d6f17c42d5
commit 07cc85ccb1
2 changed files with 2 additions and 1 deletions

View File

@@ -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);

View File

@@ -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;