diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2018-04-24 10:52:43 +0200 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@qt.io> | 2018-04-25 05:41:51 +0000 |
commit | 0ac74678fd584a1db089b90ab8892c0a39b0376b (patch) | |
tree | 90a3ffe0e12c3f8a1870605e9c9519c883a2c6fd | |
parent | 01fd723848fd6007b03c27edd85d8e9c6b6ce881 (diff) | |
download | qtmultimedia-0ac74678fd584a1db089b90ab8892c0a39b0376b.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>
(cherry picked from commit 6a2f332821ea3d8d4f6c11050d592aef0ad4df7f)
-rw-r--r-- | src/plugins/winrt/qwinrtcameraimagecapturecontrol.cpp | 8 |
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()); |