MessageQueue: Fix destructor accessing Message properties after free
This was raised as a -Wmaybe-uninitialized warning by MinGW-GCC 15.2.1.
This commit is contained in:
@ -324,19 +324,18 @@ MessageQueue::~MessageQueue() {
|
||||
|
||||
while (read_pos < buffer_end) {
|
||||
Message *message = (Message *)&buffer[read_pos];
|
||||
read_pos += sizeof(Message);
|
||||
|
||||
Variant *args = (Variant *)(message + 1);
|
||||
int argc = message->args;
|
||||
if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) {
|
||||
for (int i = 0; i < argc; i++) {
|
||||
args[i].~Variant();
|
||||
}
|
||||
read_pos += sizeof(Variant) * argc;
|
||||
}
|
||||
message->~Message();
|
||||
|
||||
read_pos += sizeof(Message);
|
||||
if ((message->type & FLAG_MASK) != TYPE_NOTIFICATION) {
|
||||
read_pos += sizeof(Variant) * message->args;
|
||||
}
|
||||
message->~Message();
|
||||
}
|
||||
|
||||
singleton = nullptr;
|
||||
|
||||
@ -55,9 +55,9 @@ class MessageQueue {
|
||||
|
||||
struct Message {
|
||||
Callable callable;
|
||||
int16_t type;
|
||||
int16_t type = 0;
|
||||
union {
|
||||
int16_t notification;
|
||||
int16_t notification = 0;
|
||||
int16_t args;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user