QEglFSKmsGbmScreen::framebufferForBufferObject: release() at the correct time

It's the gbm_bo_get_user_data() function that takes ownership of the
FrameBuffer object, not the caller of the function, so release() into
gbm_bo_set_user_data() not into the return. This threw Coverity off,
which complained about a leak of the return value in the caller.

Amends 2f0fa59d5903d4c9596ed42dcbaa9da0f77c78da, but not picking
through all the refactorings the code has since seen.

Pick-to: 6.6 6.5
Coverity-Id: 444117
Change-Id: I5f058e4a42942349193eecfd8c00ec9499ef4886
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 1cfe42235c4496f68195385507dbaa553d04aee5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-03-27 12:04:23 +01:00 committed by Qt Cherry-pick Bot
parent f84f752864
commit 5b3143fce6

View File

@ -73,8 +73,9 @@ QEglFSKmsGbmScreen::FrameBuffer *QEglFSKmsGbmScreen::framebufferForBufferObject(
return nullptr;
}
gbm_bo_set_user_data(bo, fb.get(), bufferDestroyedHandler);
return fb.release();
auto res = fb.get();
gbm_bo_set_user_data(bo, fb.release(), bufferDestroyedHandler);
return res;
}
QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless)