Skip to content

Fix memory leak in trackingRememberKeys() for PUBSUB commands#14817

Merged
ShooterIT merged 3 commits into
redis:unstablefrom
vitahlin:vitah-memleak
Feb 26, 2026
Merged

Fix memory leak in trackingRememberKeys() for PUBSUB commands#14817
ShooterIT merged 3 commits into
redis:unstablefrom
vitahlin:vitah-memleak

Conversation

@vitahlin

@vitahlin vitahlin commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

When handling PUBSUB commands, the function was returning early without calling getKeysFreeResult(), leading to a leak.


Note

Low Risk
Low risk: small control-flow change limited to client-side caching key tracking; it primarily prevents a memory leak and should not affect non-PUBSUB tracking behavior.

Overview
Fixes a memory leak in trackingRememberKeys() by returning early for CMD_PUBSUB commands before calling getKeysFromCommand(), avoiding an allocated getKeysResult that previously wasn’t freed on the PUBSUB fast path.

Written by Cursor Bugbot for commit 890ec87. This will update automatically on new commits. Configure here.

@augmentcode

augmentcode Bot commented Feb 25, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Fixes a memory leak in key-tracking when handling PUBSUB commands by ensuring key-extraction results are always freed.

Changes:

  • Call getKeysFreeResult() before the early return on CMD_PUBSUB in trackingRememberKeys()
  • Minor comment grammar tweak

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Comment thread src/tracking.c Outdated

@ShooterIT ShooterIT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, cc @sundb

@ShooterIT ShooterIT merged commit 50f1469 into redis:unstable Feb 26, 2026
18 checks passed
@vitahlin vitahlin deleted the vitah-memleak branch February 26, 2026 13:00
@YaacovHazan YaacovHazan mentioned this pull request Mar 24, 2026
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.

3 participants