Skip to content

Backport: Fix bug in DocumentEvents2 sink implementation of the ContentControlBeforeContentUpdate event#467

Merged
jozefizso merged 2 commits intomainfrom
backport/453-word-ContentControlBeforeContentUpdate-fix
Mar 25, 2026
Merged

Backport: Fix bug in DocumentEvents2 sink implementation of the ContentControlBeforeContentUpdate event#467
jozefizso merged 2 commits intomainfrom
backport/453-word-ContentControlBeforeContentUpdate-fix

Conversation

@jozefizso
Copy link
Member

@jozefizso jozefizso commented Mar 23, 2026

Backports #454. Fixes #453.

Bug fix

The DocumentEvents2_SinkHelper.ContentControlBeforeContentUpdate method had a copy-paste bug
where it called Validate("ContentControlBeforeStoreUpdate") instead of
Validate("ContentControlBeforeContentUpdate").

Because the validation used the wrong event name, the event handler would never find
registered delegates for the ContentControlBeforeContentUpdate event. This caused
the COM event parameters (specifically the contentControl dispatch object) to be
released prematurely via ReleaseParamsArray on every call, instead of being properly
dispatched to user code. The result was a memory leak, as the underlying COM objects
were not properly managed by the event handler lifecycle.

The fix corrects the event name string passed to Validate() so that the
ContentControlBeforeContentUpdate event is properly matched and dispatched to subscribers.

Changes

  • Fix the Validate() call in ContentControlBeforeContentUpdate to use the correct event name
  • Add unit tests for DocumentEvents2_SinkHelper to verify the fix
  • Update changelog for v1.9.8

…olBeforeContentUpdate` event

(cherry picked from commit 9178188)
@jozefizso jozefizso force-pushed the backport/453-word-ContentControlBeforeContentUpdate-fix branch from cd4caac to 8ea85a3 Compare March 23, 2026 17:58
@jozefizso jozefizso requested a review from DominikPalo March 24, 2026 09:58
@jozefizso jozefizso merged commit 67105f0 into main Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory leak in the method NetOffice.WordApi.Events.DocumentEvents2_SinkHelper.ContentControlBeforeContentUpdate

3 participants