Commit 4eda4d2b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

drm: prevent cursor buffer leakage

Use smart pointers to make sure we don't dereference valid pointers.
parent edb61593
......@@ -87,10 +87,8 @@ void DrmOutput::teardown()
m_crtc->setOutput(nullptr);
m_conn->setOutput(nullptr);
delete m_cursor[0];
m_cursor[0] = nullptr;
delete m_cursor[1];
m_cursor[1] = nullptr;
m_cursor[0].reset(nullptr);
m_cursor[1].reset(nullptr);
if (!m_pageFlipPending) {
deleteLater();
} //else will be deleted in the page flip handler
......@@ -125,7 +123,7 @@ bool DrmOutput::showCursor()
return true;
}
const bool ret = showCursor(m_cursor[m_cursorIndex]);
const bool ret = showCursor(m_cursor[m_cursorIndex].data());
if (!ret) {
return ret;
}
......@@ -464,7 +462,7 @@ bool DrmOutput::initCursorPlane() // TODO: Add call in init (but needs lay
bool DrmOutput::initCursor(const QSize &cursorSize)
{
auto createCursor = [this, cursorSize] (int index) {
m_cursor[index] = m_backend->createBuffer(cursorSize);
m_cursor[index].reset(m_backend->createBuffer(cursorSize));
if (!m_cursor[index]->map(QImage::Format_ARGB32_Premultiplied)) {
return false;
}
......
......@@ -182,7 +182,7 @@ private:
QPoint globalPos;
bool valid = false;
} m_lastWorkingState;
DrmDumbBuffer *m_cursor[2] = {nullptr, nullptr};
QScopedPointer<DrmDumbBuffer> m_cursor[2];
int m_cursorIndex = 0;
bool m_hasNewCursor = false;
bool m_deleted = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment