summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-11-04 21:58:19 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-11-04 21:58:19 (GMT)
commitd95cc48ae17e1cae4d067cc0ed8d795b244b5299 (patch)
tree47001458254c4970478f97711173e13d22945f65
parentb410e7f08ced8741ca8c83bb45083e944b9fb278 (diff)
Fix memory leak when building with a11y support
QAccessible::updateAccessibility() expects a pointer, but doesn't take ownership of the argument and expects us to delete it after we've called it. So just allocate the object on the stack like other users of this API do. Found by ASAN.
-rw-r--r--src/TerminalDisplay.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index ad444f6..a609c19 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -1259,8 +1259,10 @@ void TerminalDisplay::updateImage()
delete[] dirtyMask;
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(new QAccessibleEvent(this, QAccessible::VisibleDataChanged));
- QAccessible::updateAccessibility(new QAccessibleTextCursorEvent(this, _usedColumns * screenWindow()->screen()->getCursorY() + screenWindow()->screen()->getCursorX()));
+ QAccessibleEvent dataChangeEvent(this, QAccessible::VisibleDataChanged);
+ QAccessible::updateAccessibility(&dataChangeEvent);
+ QAccessibleTextCursorEvent cursorEvent(this, _usedColumns * screenWindow()->screen()->getCursorY() + screenWindow()->screen()->getCursorX());
+ QAccessible::updateAccessibility(&cursorEvent);
#endif
}
@@ -3143,7 +3145,8 @@ void TerminalDisplay::keyPressEvent(QKeyEvent* event)
emit keyPressedSignal(event);
#ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(new QAccessibleTextCursorEvent(this, _usedColumns * screenWindow()->screen()->getCursorY() + screenWindow()->screen()->getCursorX()));
+ QAccessibleTextCursorEvent textCursorEvent(this, _usedColumns * screenWindow()->screen()->getCursorY() + screenWindow()->screen()->getCursorX());
+ QAccessible::updateAccessibility(&textCursorEvent);
#endif
event->accept();