<table><tr><td style="">dvratil created this revision.<br />dvratil added a reviewer: KWin.<br />Herald added a project: Frameworks.<br />Herald added a subscriber: kde-frameworks-devel.<br />dvratil requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D27538">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>Instead just unref it, because the wl_display_dispatch_queue_pending<br />
will try to destroy the callback afterwards as well, leading to<br />
invalid read/write.</p>

<p>Fixes Valgrind warnings when running KScreen tests:</p>

<h3 class="remarkup-header">460922== Invalid read of size 4</h3>

<h3 class="remarkup-header">460922==    at 0x5CE5B34: wl_proxy_unref (wayland-client.c:230)</h3>

<h3 class="remarkup-header">460922==    by 0x5CE5C33: destroy_queued_closure (wayland-client.c:292)</h3>

<h3 class="remarkup-header">460922==    by 0x5CE74AB: dispatch_queue (wayland-client.c:1591)</h3>

<h3 class="remarkup-header">460922==    by 0x5CE74AB: wl_display_dispatch_queue_pending (wayland-client.c:1833)</h3>

<h3 class="remarkup-header">460922==    by 0x4E0240D: KWayland::Client::EventQueue::dispatch() (src/frameworks/kwayland/src/client/event_queue.cpp:96)</h3>

<p>g==460922==  Address 0x17233aac is 44 bytes inside a block of size 80 free'd</p>

<h3 class="remarkup-header">460922==    at 0x483B9F5: free (vg_replace_malloc.c:540)</h3>

<h3 class="remarkup-header">460922==    by 0x4E15B60: destroy (src/frameworks/kwayland/src/client/wayland_pointer_p.h:63)</h3>

<h3 class="remarkup-header">460922==    by 0x4E15B60: KWayland::Client::Registry::Private::globalSync(void*, wl_callback*, unsigned int) (src/frameworks/kwayland/src/client/registry.cpp:548)</h3>

<p>...</p>

<h3 class="remarkup-header">460922==    by 0x5CE74AB: dispatch_queue (wayland-client.c:1591)</h3>

<h3 class="remarkup-header">460922==    by 0x5CE74AB: wl_display_dispatch_queue_pending (wayland-client.c:1833)</h3>

<h3 class="remarkup-header">460922==    by 0x4E0240D: KWayland::Client::EventQueue::dispatch() (src/frameworks/kwayland/src/client/event_queue.cpp:96)</h3></div></div><br /><div><strong>TEST PLAN</strong><div><p>Run testkwaylandbackend from libkscreen under Valgrind - no more invalid reads</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R127 KWayland</div></div></div><br /><div><strong>BRANCH</strong><div><div>master</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D27538">https://phabricator.kde.org/D27538</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/client/registry.cpp</div></div></div><br /><div><strong>To: </strong>dvratil, KWin<br /><strong>Cc: </strong>kde-frameworks-devel, LeGast00n, cblack, GB_2, michaelh, ngraham, bruns<br /></div>