Skip to content

fix: fix memory leak in separator module and replace exit(1) in publicip - #2477

Merged
CarterLi merged 2 commits into
fastfetch-cli:devfrom
h4sht:fix/separator-publicip-leaks-and-exit
Jul 24, 2026
Merged

fix: fix memory leak in separator module and replace exit(1) in publicip#2477
CarterLi merged 2 commits into
fastfetch-cli:devfrom
h4sht:fix/separator-publicip-leaks-and-exit

Conversation

@h4sht

@h4sht h4sht commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Memory leak in separator module

ffInitSeparatorOptions calls ffStrbufInit(&options->outputColor) but ffDestroySeparatorOptions was missing the corresponding ffStrbufDestroy. This leaks memory whenever a user sets a custom output color via JSON config.

Fix: Added ffStrbufDestroy(&options->outputColor) to ffDestroySeparatorOptions.

Aggressive exit(1) in publicip module

ffPreparePublicIp had two exit(1) calls:

  1. When the module is used more than once
  2. When an unsupported URL protocol is specified

Both killed the entire process instead of propagating the error properly.

Fix: Both exit(1) calls are replaced with setting *status to an error string and returning. The error is properly propagated through the existing mechanism (ffDetectPublicIp already checks if (*status != nullptr) return *status;). This matches the pattern already used in the weather module.

Files changed

  • src/modules/separator/separator.c: Added missing ffStrbufDestroy(&options->outputColor)
  • src/detection/publicip/publicip.c: Replaced two exit(1) calls with proper error propagation

tru3 added 2 commits July 24, 2026 08:48
- Add missing ffStrbufDestroy(&options->outputColor) in ffDestroySeparatorOptions
  to prevent memory leak when outputColor is set via JSON config
- Replace two exit(1) calls in ffPreparePublicIp with proper error status
  propagation, matching the pattern used in the weather module
- Add missing ffStrbufDestroy(&options->outputColor) in ffDestroySeparatorOptions
  to prevent memory leak when outputColor is set via JSON config
- Replace two exit(1) calls in ffPreparePublicIp with proper error status
  propagation, matching the pattern used in the weather module
@CarterLi
CarterLi force-pushed the fix/separator-publicip-leaks-and-exit branch from b7ac175 to 2928f65 Compare July 24, 2026 00:49
@CarterLi
CarterLi merged commit ccf3909 into fastfetch-cli:dev Jul 24, 2026
17 of 18 checks passed
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.

2 participants