From b6f280aedb5bc6211a5b71b789841b21157fcde4 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sat, 27 May 2017 06:14:00 +0200 Subject: [PATCH] tests: fix memory access in testnotificationlistener set the image data as QByteArray of the right size, otherwise referencing a stack-based char data will be problematic when the function is out of scope --- tests/testnotificationlistener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testnotificationlistener.cpp b/tests/testnotificationlistener.cpp index 5255c1c4..e82bc4dd 100644 --- a/tests/testnotificationlistener.cpp +++ b/tests/testnotificationlistener.cpp @@ -426,7 +426,7 @@ void TestNotificationListener::testNotify() 0x31, 0x32, 0x33, 0x34 }; QVariantMap imageData = {{"width", width}, {"height", height}, {"rowStride", rowStride}, {"bitsPerSample", bitsPerSample}, {"channels", channels}, - {"hasAlpha", hasAlpha}, {"imageData", rawData}}; + {"hasAlpha", hasAlpha}, {"imageData", QByteArray(rawData, sizeof(rawData))}}; QVariantMap hints; #define COMPARE_PIXEL(x, y) \ QCOMPARE(qRed(image.pixel(x,y)), (int)rawData[x*4 + y*rowStride + 0]); \ -- GitLab