Repository navigation
[6235] 修复 bridge_argument_rep::notify_change 空指针解引用导致的闪退 - #4768
Merged
Merged
Conversation
da-liii
reviewed
Nov 3, 2026
| if ((!valid) || (name != name2) || (prefix != pf) || (body->st != b_t) || | ||
| (body->ip != b_ip)) { | ||
| if ((!valid) || is_nil (body) || (name != name2) || (prefix != pf) || | ||
| (body->st != b_t) || (body->ip != b_ip)) { |
Contributor
Author
There was a problem hiding this comment.
body->st是旧的,已经排版好的内容的语法书。b_t是新的内容的语法树,如果两者相同,就没必要重新排版,而是复用旧的body及其排版效果。
ip是路径偏移,因为内容可能没有变化,但是文档前面插入或者删除了一段话,这导致路径偏移出现了位移,这时候也必须触发更新
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.
缺陷描述
在包含复杂排版或宏包(如
preview-ref)的文档中,选中文档内容并执行剪切/退格删除/替换操作时,软件偶发或必现闪退(SIGSEGV)。崩溃发生在
bridge_argument_rep::notify_change()(src/Typeset/Bridge/bridge_argument.cpp),由于对未完成排版的参数桥接节点解引用空指针body(0x0000000000000000)。修复思路
bridge_argument_rep::notify_change()中增加判空保护:if (!is_nil (body)) body->notify_change ();。bridge_argument_rep::initialize()与notify_macro()中增加针对body为 nil 状态的判断与防御。bridge_expand_as_rep::notify_change()补充同样的判空保护。tests/Typeset/Bridge/bridge_argument_test.cpp,覆盖 un-typesetbridge_argument节点直接notify_change以及通过文档notify_remove级联触发通知的场景。验证
xmake b bridge_argument_test && xmake r bridge_argument_test全部通过(4 passed,0 failed)。