3
26
Fork
You've already forked mere
1

Preserve diagnostic context in createRepoCachesForBuild; fix leaks and a double-free in repo_sources.zig #110

Merged
jhuntwork merged 1 commit from repo-caches-diagnostic-context-guard into main 2026年07月11日 00:49:43 +02:00

createRepoCachesForBuild unconditionally overwrote whatever diagnostic
context repo_sources.createCaches already set (e.g. a specific repo
name and "failed to initialize repository cache") with a generic
"config"/"failed to create repo caches from config", inconsistent with
mapBuildCacheError's guarded pattern elsewhere in this file. Guarded it
the same way.

Also fixed three bugs in repo_sources.zig's loadTrustedFingerprints:

  • The mere.pub fingerprint string was orphaned if the subsequent
    fingerprints.append() call failed (OOM) before it was added to the
    list the function's own errdefer cleans up.
  • Same leak pattern for a trusted.kdl fingerprint entry's dupe-then-append.
  • The trusted.kdl content buffer was freed by both an errdefer
    registered right after allocating it and a second, redundant
    unconditional defer registered later - any error after the second
    defer double-freed it.

Also fixed test_helpers.createTestRepoConfig, which referenced a
nonexistent .ctx field on RepoConfig - needed for the new
createRepoCachesForBuild test.

createRepoCachesForBuild unconditionally overwrote whatever diagnostic context repo_sources.createCaches already set (e.g. a specific repo name and "failed to initialize repository cache") with a generic "config"/"failed to create repo caches from config", inconsistent with mapBuildCacheError's guarded pattern elsewhere in this file. Guarded it the same way. Also fixed three bugs in repo_sources.zig's loadTrustedFingerprints: - The mere.pub fingerprint string was orphaned if the subsequent fingerprints.append() call failed (OOM) before it was added to the list the function's own errdefer cleans up. - Same leak pattern for a trusted.kdl fingerprint entry's dupe-then-append. - The trusted.kdl content buffer was freed by both an errdefer registered right after allocating it and a second, redundant unconditional defer registered later - any error after the second defer double-freed it. Also fixed test_helpers.createTestRepoConfig, which referenced a nonexistent .ctx field on RepoConfig - needed for the new createRepoCachesForBuild test.
createRepoCachesForBuild unconditionally overwrote whatever diagnostic
context repo_sources.createCaches already set (e.g. a specific repo
name and "failed to initialize repository cache") with a generic
"config"/"failed to create repo caches from config", inconsistent with
mapBuildCacheError's guarded pattern elsewhere in this file. Guarded it
the same way.
Also fixed three bugs in repo_sources.zig's loadTrustedFingerprints:
- The mere.pub fingerprint string was orphaned if the subsequent
 fingerprints.append() call failed (OOM) before it was added to the
 list the function's own errdefer cleans up.
- Same leak pattern for a trusted.kdl fingerprint entry's dupe-then-append.
- The trusted.kdl content buffer was freed by both an errdefer
 registered right after allocating it and a second, redundant
 unconditional defer registered later - any error after the second
 defer double-freed it.
Also fixed test_helpers.createTestRepoConfig, which referenced a
nonexistent .ctx field on RepoConfig - needed for the new
createRepoCachesForBuild test.
jhuntwork deleted branch repo-caches-diagnostic-context-guard 2026年07月11日 00:49:43 +02:00
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
merelinux/mere!110
Reference in a new issue
merelinux/mere
No description provided.
Delete branch "repo-caches-diagnostic-context-guard"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?