summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-04-24 10:52:43 +0200
committerOliver Wolff <oliver.wolff@qt.io>2018-04-24 11:57:29 +0000
commit6a2f332821ea3d8d4f6c11050d592aef0ad4df7f (patch)
treefea34807d850933f3f77fe90cdea56f568dab9c9
parentcebad2c2a97eb29b81664cd8027121642d0ec93b (diff)
downloadqtmultimedia-6a2f332821ea3d8d4f6c11050d592aef0ad4df7f.tar.gz
winrt: Do not use CoTaskMemFree as image cleanup function
CoTaskMemFree is declared __stdcall. This declaration causes a stack maintenance behavior (called function pops its own arguments from the stack) that breaks release builds and leads to crashes. By wrapping that function into our own function (which is by default __cdecl) we get the wanted stack maintenance behavior (calling function pops arguments from the stack) and thus avoid these crashes. Task-number: QTBUG-63016 Change-Id: Ibd36f4fc2680351bf41c2991e9b3f1723bb19eab Reviewed-by: Andre de la Rocha <andre.rocha@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> Reviewed-by: VaL Doroshchuk <valentyn.doroshchuk@qt.io>
-rw-r--r--src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp b/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp
index 54f4b103b..f4903c5a1 100644
--- a/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp
+++ b/src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp
@@ -106,6 +106,12 @@ struct CaptureRequest
ComPtr<IAsyncAction> op;
};
+// Do not use CoTaskMemFree directly for image cleanup as it leads to crashes in release
+static void freeImageData(void *data)
+{
+ CoTaskMemFree(data);
+}
+
class QWinRTCameraImageCaptureControlPrivate
{
public:
@@ -296,7 +302,7 @@ HRESULT QWinRTCameraImageCaptureControl::onCaptureCompleted(IAsyncAction *asyncI
hr = frame->get_PixelWidth(&pixelWidth);
Q_ASSERT_SUCCEEDED(hr);
const QImage image(pixelData, pixelWidth, pixelHeight, QImage::Format_RGBA8888,
- reinterpret_cast<QImageCleanupFunction>(&CoTaskMemFree), pixelData);
+ reinterpret_cast<QImageCleanupFunction>(&freeImageData), pixelData);
emit imageCaptured(request.id, image);
QWinRTImageEncoderControl *imageEncoderControl = static_cast<QWinRTImageEncoderControl*>(d->cameraControl->imageEncoderControl());