Skip to content

fix: ddialog's lambda func may cause segfault - #620

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
rb-union:master
Nov 22, 2024
Merged

fix: ddialog's lambda func may cause segfault#620
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
rb-union:master

Conversation

@rb-union

Copy link
Copy Markdown
Contributor

DDialog 的 onButtonClickedClose 标记默认是 true.
exec() 下绑定的 lambda 函数在 exec() 调用后没有断开连接,复用对话框,调用 exec() 会连接多个 lambda 槽函数。
而这个lambda函数捕获临时变量,这个临时地址可能和后续其它的变量地址重合,变量被覆写后再访问可能触发段错误。

尝试直接用done()传入resultCode,就不用关联信号了。
请审核下没考虑的问题或更优方案。

deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Nov 21, 2024
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#620
deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Nov 22, 2024
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#620
Comment thread src/widgets/ddialog.cpp
During call DDialog::exec(), the onButtonClickedClose
flag is set to true by default.
At this point, DDialog connect lambda function captures the
**temporary variable**, and does not disconnect the signal
after the exec() call ends.
As a result of calling the same dialog object multiple times,
other addresses may be **overwritten** by previous temporary
variable writes, causing segfault (crashes).

Use done() to set the return value instead of via connect
lambda function.

Log: Fixed a bug that may cause segfault.
deepin-ci-robot added a commit to linuxdeepin/dtk6widget that referenced this pull request Nov 22, 2024
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#620
@deepin-bot

deepin-bot Bot commented Nov 22, 2024

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 5.7.3
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #619

@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kegechen, rb-union

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rb-union

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 22, 2024

Copy link
Copy Markdown
Contributor

This pr force merged! (status: behind)

@deepin-bot
deepin-bot Bot merged commit 3fb2ebd into linuxdeepin:master Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants