Compare
00fa85023543f86bb7fe71e6ed75a1ab5fb7dfe8..95d48952cc66b299554ebd90aada5c3fbc2a6e7d
repository: make repo_clear() idempotent
Calling repo_clear() twice in a row will segfault because the second call will invoke parse_object_pool_clear() on a NULL pointer. This is not usually a big deal, but we can make some error cleanup a little simpler if callers do not need to worry about invoking it twice. We can fix it by catching the NULL case. The rest of repo_clear() appears to be idempotent. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King <peff@peff.net> · 2026-09-02 05:55 UTC · committed by Junio C Hamano
3 files changed,
+8
−7
modified .github/workflows/main.yml
| @@ -411,9 +411,9 @@ jobs: | |||
| 411 | 411 | # A RHEL 8 compatible distro. Supported until 2029-05-31. | |
| 412 | 412 | - jobname: almalinux-8 | |
| 413 | 413 | image: almalinux:8 | |
| 414 | - | # Supported until 2028-06-30. | |
| 415 | - | - jobname: debian-12 | |
| 416 | - | image: debian:12 | |
| 414 | + | # Supported until 2026-08-31. | |
| 415 | + | - jobname: debian-11 | |
| 416 | + | image: debian:11 | |
| 417 | 417 | env: | |
| 418 | 418 | jobname: ${{matrix.vector.jobname}} | |
| 419 | 419 | CC: ${{matrix.vector.cc}} | |
modified .gitlab-ci.yml
| @@ -71,9 +71,9 @@ test:linux: | |||
| 71 | 71 | # A RHEL 8 compatible distro. Supported until 2029-05-31. | |
| 72 | 72 | - jobname: almalinux-8 | |
| 73 | 73 | image: almalinux:8 | |
| 74 | - | # Supported until 2028-06-30. | |
| 75 | - | - jobname: debian-12 | |
| 76 | - | image: debian:12 | |
| 74 | + | # Supported until 2026-08-31. | |
| 75 | + | - jobname: debian-11 | |
| 76 | + | image: debian:11 | |
| 77 | 77 | artifacts: | |
| 78 | 78 | paths: | |
| 79 | 79 | - t/failed-test-artifacts | |
modified repository.c
| @@ -384,7 +384,8 @@ void repo_clear(struct repository *repo) | |||
| 384 | 384 | odb_free(repo->objects); | |
| 385 | 385 | repo->objects = NULL; | |
| 386 | 386 | ||
| 387 | - | parsed_object_pool_clear(repo->parsed_objects); | |
| 387 | + | if (repo->parsed_objects) | |
| 388 | + | parsed_object_pool_clear(repo->parsed_objects); | |
| 388 | 389 | FREE_AND_NULL(repo->parsed_objects); | |
| 389 | 390 | ||
| 390 | 391 | repo_settings_clear(repo); | |