Skip to content

Release previous item reference in cbor_tag_set_item() - #391

Merged
PJK merged 1 commit into
masterfrom
fix-tag-set-item-leak
Feb 8, 2026
Merged

PJK merged 1 commit into
masterfrom
fix-tag-set-item-leak

Conversation

@PJK

@PJK PJK commented Feb 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • cbor_tag_set_item() did not decref the previous tagged item when replacing it, leaking the reference
  • Now decrefs the old item before setting the new one, consistent with cbor_array_replace()
  • Updated documentation to reflect the new behavior (removed the TODO)

Breaking change

Previously, replacing the tagged item would leak the old item's reference. If callers were manually releasing the old item before calling cbor_tag_set_item, they should remove the extra cbor_decref.

Test plan

  • Added test_set_item_replaces_previous verifying refcounts are correctly updated when replacing a tagged item
  • All 26 test binaries pass
  • clang-format clean

🤖 Generated with Claude Code

cbor_tag_set_item() did not decref the previous tagged item when
replacing it, leaking the reference. Now it decrefs the old item
before setting the new one, consistent with cbor_array_replace().

This is a breaking change for callers that manually released the
old item before calling cbor_tag_set_item.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@PJK
PJK merged commit 4b025b1 into master Feb 8, 2026
15 of 16 checks passed
@PJK
PJK deleted the fix-tag-set-item-leak branch February 8, 2026 17:56
@codecov

codecov Bot commented Feb 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (502f690) to head (f9e8c52).
⚠️ Report is 32 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #391   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines         1659      1661    +2     
=========================================
+ Hits          1659      1661    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

⌂ 换网址