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:
Rémi Verschelde 2025-10-29 13:08:05 +01:00
parent 0687d5f29f
commit 318a9721b8
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 6 additions and 7 deletions

View file

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

View file

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