fix: prevent double-decref of event in envelope add functions#1511
Merged
jpnurmi merged 2 commits intogetsentry:masterfrom Feb 11, 2026
Merged
fix: prevent double-decref of event in envelope add functions#1511jpnurmi merged 2 commits intogetsentry:masterfrom
jpnurmi merged 2 commits intogetsentry:masterfrom
Conversation
Move `item->event` assignment after the payload allocation check in `sentry__envelope_add_event` and `sentry__envelope_add_transaction`. Previously, if `sentry__jsonwriter_into_string` failed, the event was already owned by the envelope item. Multiple callers decref the event and free the envelope on failure, leading to a double-decref because `sentry_envelope_free` also decrefs `item->event` via item cleanup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mujacica
approved these changes
Feb 11, 2026
supervacuus
approved these changes
Feb 11, 2026
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.
Move
item->eventassignment after the payload allocation check insentry__envelope_add_eventandsentry__envelope_add_transaction. This fixes the inconsistency between the various failure paths that this accidentally took ownership whereas the others don't, making it unsafe to decref the event on failure at the call-site.Previously, if
sentry__jsonwriter_into_stringfailed, the event was already owned by the envelope item. Existing callers decref the event and free the envelope on failure, leading to a double-decref becausesentry_envelope_freealso decrefsitem->eventvia item cleanup:Resolves #1493 (comment)