Skip to content

fix: resolve DisplayAttributeInfoEnum UAF, atomic COM refCount, and null guards - #13

Merged
PCMan merged 2 commits into
masterfrom
fix/com-uaf-and-guards
Oct 24, 2026
Merged

PCMan merged 2 commits into
masterfrom
fix/com-uaf-and-guards

Conversation

@PCMan

@PCMan PCMan commented Oct 24, 2026

Copy link
Copy Markdown
Member

This pull request resolves several memory safety and stability issues in libIME2:

  • DisplayAttributeInfoEnum UAF (PIME #883): In DisplayAttributeInfoEnum.cpp, displayAttrInfos was previously bound as a value copy of the container (auto displayAttrInfos = ...), causing iterator_ to become dangling once the constructor exited. In applications like Microsoft Word that enumerate display attributes, accessing the iterator led to heap corruption and crashes. Binding by reference (auto& displayAttrInfos) fixes this.
  • Thread-safe COM Reference Counting: Replaced non-atomic ++refCount_ and --refCount_ in ComObject.h with InterlockedIncrement and InterlockedDecrement with volatile LONG refCount_ to ensure thread-safe lifetime management across multi-threaded COM calls.
  • Null Safety in TextService: Added null-pointer checks for threadMgr_ and docMgr in TextService::currentContext().
  • CandidateWindow Bounds Guards: Guarded selKeys_ indexing in recalculateSize() and paintItem() against out-of-bounds access when items_ exceeds selKeys_, and clamped candPerRow = std::max(1, candPerRow_) in itemRect() to prevent division by zero.

Generated with assistance from Antigravity (Gemini 3.8 Flash)

PCMan added 2 commits October 24, 2026 14:37
…extService

- Guard selKeys_ bounds in CandidateWindow recalculateSize and paintItem, and clamp candPerRow in itemRect to prevent division by zero.
- Add null-checks for threadMgr_ and docMgr in TextService::currentContext().

Generated with assistance from Antigravity (Gemini 3.8 Flash)
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.

1 participant