From 456106d749d1b4ab826741c00f46ffa24e693b51 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 11 Sep 2020 14:01:55 +0300 Subject: [PATCH] autotests: Fix ASAN issues in TestWaylandSurface::testStaticAccessor We need to store surface ids before destroying the corresponding surfaces in order to avoid heap-use-after-free errors. --- src/wayland/autotests/client/test_wayland_surface.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wayland/autotests/client/test_wayland_surface.cpp b/src/wayland/autotests/client/test_wayland_surface.cpp index 3169bc8e92..6ca9ec03bb 100644 --- a/src/wayland/autotests/client/test_wayland_surface.cpp +++ b/src/wayland/autotests/client/test_wayland_surface.cpp @@ -224,6 +224,9 @@ void TestWaylandSurface::testStaticAccessor() QCOMPARE(KWaylandServer::SurfaceInterface::get(serverSurface2->resource()), serverSurface2); QCOMPARE(KWaylandServer::SurfaceInterface::get(serverSurface2->id(), serverSurface2->client()), serverSurface2); + const quint32 surfaceId1 = serverSurface1->id(); + const quint32 surfaceId2 = serverSurface2->id(); + // delete s2 again delete s2; QCOMPARE(KWayland::Client::Surface::all().count(), 1); @@ -238,8 +241,8 @@ void TestWaylandSurface::testStaticAccessor() QVERIFY(destroyedSpy.isValid()); QVERIFY(destroyedSpy.wait()); QVERIFY(!KWaylandServer::SurfaceInterface::get(nullptr)); - QVERIFY(!KWaylandServer::SurfaceInterface::get(serverSurface1->id(), nullptr)); - QVERIFY(!KWaylandServer::SurfaceInterface::get(serverSurface2->id(), nullptr)); + QVERIFY(!KWaylandServer::SurfaceInterface::get(surfaceId1, nullptr)); + QVERIFY(!KWaylandServer::SurfaceInterface::get(surfaceId2, nullptr)); } void TestWaylandSurface::testDamage()