Fix unsafe resource lifetimes found by repository audit - #1524
Open
bmehta001 wants to merge 1 commit into
Open
Conversation
Correct four independent ownership defects that can over-release borrowed CoreFoundation data, leak a newly created manager on registry allocation failure, corrupt self-assigned EventProperty values, or pair array allocations with scalar deletion. Files changed: - examples/cpp/MacProxy/main.cpp: preserve borrowed proxy values and guard empty proxy arrays. - lib/api/LogManagerFactory.cpp: retain manager ownership until registry insertion succeeds. - lib/system/EventProperty.cpp: make copy self-assignment safe. - lib/tracing/api/DebugProviders.hpp: pair new[] buffers with delete[]. - tests/unittests/EventPropertiesTests.cpp: cover EventProperty self-assignment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d7d2f27a-7339-4585-ad02-9f89ce20ef40
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.
Description
Fix four independent resource-lifetime defects found by a repository-wide audit of first-party cleanup and ownership paths:
hostNameRefreturned byCFDictionaryGetValue; it is borrowed from the proxy dictionary. Also avoid indexing an empty proxy array.LogManagerImplin aunique_ptruntil insertion into the global manager registry succeeds, preventing an exception-path leak.EventPropertycopy self-assignment a no-op instead of clearing its own source storage and then dereferencing it.new[]allocations in ETW provider GUID generation withdelete[]rather than scalardelete.The audit excluded vendored/generated code. WinInet and curl cancellation lifetime findings are intentionally not duplicated here because #1520 already rewrites those ownership paths.
Validation
MATSDK_WARNINGS_AS_ERRORS=ON.EventPropertiesTestssuite.