fix(test): resolve ASAN heap-buffer-overflow in textedit unit tests - #504
Closed
pengfeixx wants to merge 1 commit into
Closed
fix(test): resolve ASAN heap-buffer-overflow in textedit unit tests#504pengfeixx wants to merge 1 commit into
pengfeixx wants to merge 1 commit into
Conversation
Add stubs for insertMultiTextEx, deleteMultiTextEx and slotCanUndoChanged to prevent unsafe Window pointer access via EditWrapper::window() when no real Window parent exists. 修复单元测试中因 EditWrapper 缺少 Window 父对象导致的堆越界崩溃, 通过 stub 隔离 undo 栈信号链中的 Window 访问路径。 同时修复源码中 slotCanUndoChanged/slotCanRedoChanged 的空指针 解引用风险,使用 dynamic_cast 替代直接调用,增加 m_wrapper 空检查。 修复 Tabbar::eventFilter 事件过滤范围过宽的问题。 修复 Qt6 API 兼容性(QMouseEvent/QHoverEvent 构造函数变更)。 修复 resizeEvent lambda 中的悬空指针风险(使用 QPointer 保护)。 修复 Window::checkBlockShutdown 空标签文本的越界访问。 Log: 修复单元测试ASAN堆越界崩溃及多处空指针/类型安全问题 Influence: 修复后单元测试不再因类型混淆和堆越界崩溃,提升测试稳定性;源码修复消除了 slotCanUndoChanged 等路径中的空指针解引用和悬空指针风险。
There was a problem hiding this comment.
Sorry @pengfeixx, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideAdds safer undo/redo handling and Qt6-compatible test code to eliminate ASAN heap-buffer-overflow and null/dangling pointer risks in TextEdit, Tabbar, Window, and related unit tests. Sequence diagram for safer TextEdit undo/redo modify-status updatessequenceDiagram
participant UndoStack
participant TextEdit
participant EditWrapper
participant Window
UndoStack->>TextEdit: canUndoChanged(bool)
TextEdit->>TextEdit: slotCanUndoChanged(bool)
TextEdit->>TextEdit: [check m_wrapper != nullptr]
TextEdit->>EditWrapper: isTemFile()
TextEdit->>UndoStack: canUndo()
TextEdit->>UndoStack: index()
TextEdit->>TextEdit: compute isModified
TextEdit->>EditWrapper: window()
TextEdit->>TextEdit: [cast to Window succeeds]
TextEdit->>Window: updateModifyStatus(m_sFilePath, isModified)
TextEdit->>EditWrapper: OnUpdateHighlighter()
UndoStack->>TextEdit: canRedoChanged(bool)
TextEdit->>TextEdit: slotCanRedoChanged(bool)
TextEdit->>TextEdit: [check m_wrapper != nullptr]
TextEdit->>EditWrapper: isTemFile()
TextEdit->>UndoStack: canUndo()
TextEdit->>UndoStack: index()
TextEdit->>TextEdit: compute isModified
TextEdit->>EditWrapper: window()
TextEdit->>TextEdit: [cast to Window succeeds]
TextEdit->>Window: updateModifyStatus(m_sFilePath, isModified)
TextEdit->>EditWrapper: OnUpdateHighlighter()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add stubs for insertMultiTextEx, deleteMultiTextEx and slotCanUndoChanged to prevent unsafe Window pointer access via EditWrapper::window() when no real Window parent exists.
修复单元测试中因 EditWrapper 缺少 Window 父对象导致的堆越界崩溃,
通过 stub 隔离 undo 栈信号链中的 Window 访问路径。
同时修复源码中 slotCanUndoChanged/slotCanRedoChanged 的空指针 解引用风险,使用 dynamic_cast 替代直接调用,增加 m_wrapper 空检查。
修复 Tabbar::eventFilter 事件过滤范围过宽的问题。
修复 Qt6 API 兼容性(QMouseEvent/QHoverEvent 构造函数变更)。
修复 resizeEvent lambda 中的悬空指针风险(使用 QPointer 保护)。
修复 Window::checkBlockShutdown 空标签文本的越界访问。
Log: 修复单元测试ASAN堆越界崩溃及多处空指针/类型安全问题
Influence: 修复后单元测试不再因类型混淆和堆越界崩溃,提升测试稳定性;源码修复消除了 slotCanUndoChanged 等路径中的空指针解引用和悬空指针风险。
Summary by Sourcery
Fix text editor tests and core components to address ASAN heap-buffer-overflow, null-pointer risks, and Qt6 API compatibility issues.
Bug Fixes:
Enhancements:
Build:
Documentation:
Tests: