Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 21, 2026

Addresses feedback from #334: realpath(info.dli_fname, nullptr) allocates heap memory that was never freed.

Changes

  • Replace dynamic allocation with static buffer _profiler_path[PATH_MAX], matching the pattern in patch_library_unlocked()
  • Add null check with fallback to info.dli_fname when realpath() fails (e.g., virtual files, permission errors)
// Before
_profiler_name = realpath(info.dli_fname, nullptr);  // malloc'd, never freed

// After
static char _profiler_path[PATH_MAX];
_profiler_name = realpath(info.dli_fname, _profiler_path);
if (_profiler_name == nullptr) {
  _profiler_name = info.dli_fname;  // fallback on error
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Address feedback on handling soft links in library paths Fix memory leak in LibraryPatcher::initialize() Jan 21, 2026
Copilot AI requested a review from jbachorik January 21, 2026 08:46
@jbachorik jbachorik requested a review from zhengyu123 January 21, 2026 08:59
@jbachorik jbachorik marked this pull request as ready for review January 21, 2026 08:59
@zhengyu123
Copy link
Contributor

No, this is not a leak, _profiler_name is immortal.

@zhengyu123 zhengyu123 closed this Jan 21, 2026
@zhengyu123
Copy link
Contributor

Not a leak.

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