From: Michael Gilbert Date: Wed, 6 Jul 2022 00:44:32 +0000 (+0100) Subject: use buf before passing it to realloc (gcc 12 -Wuse-after-free) X-Git-Tag: archive/raspbian/7.0_repack-10+rpi1~3^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c5a474d70f3b8ebeb9770f8dcd78ef5748f26a71;p=wine.git use buf before passing it to realloc (gcc 12 -Wuse-after-free) Gbp-Pq: Topic warnings Gbp-Pq: Name use-after-free.patch --- diff --git a/server/queue.c b/server/queue.c index 4f69a08..a9aa955 100644 --- a/server/queue.c +++ b/server/queue.c @@ -3334,13 +3334,15 @@ DECL_HANDLER(get_rawinput_buffer) if (cur + data->size > buf + get_reply_max_size()) break; if (cur + data->size > buf + buf_size) { + ptrdiff_t diff = cur - buf; + buf_size += buf_size / 2 + extra_size; if (!(tmp = realloc( buf, buf_size ))) { set_error( STATUS_NO_MEMORY ); return; } - cur = tmp + (cur - buf); + cur = tmp + diff; buf = tmp; }