From 90dde6b70f18447ff3481ce97d99a81b49536b5f Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 11 Jan 2026 16:26:48 -0600 Subject: [PATCH] Bugfix: The fl_path_canonical() is not consistently resetting canonical.used. The `fl_path_canonical()` is replacing the `canonical` variable rather than appending to it. However, when `path.used` is 0, then the current path is appended without resetting `canonical.used` to 0. Ensure that `canonical.used` is always set to 0 to enforce replacement. Add explicit documentation comment making it clear that this function performs a replacement rather than an append. --- level_1/fl_path/c/path.c | 4 ++-- level_1/fl_path/c/path.h | 1 + .../fl_path/data/documentation/man/man3/fl_path_canonical.3 | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/level_1/fl_path/c/path.c b/level_1/fl_path/c/path.c index 84630665e..fe5f82ee9 100644 --- a/level_1/fl_path/c/path.c +++ b/level_1/fl_path/c/path.c @@ -12,6 +12,8 @@ extern "C" { f_status_t status = F_okay; + canonical->used = 0; + if (!path.used) { status = f_path_current(F_true, canonical); if (F_status_is_error(status)) return status; @@ -26,8 +28,6 @@ extern "C" { f_number_unsigned_t size_chunk = 0; f_number_unsigned_t position = 0; - canonical->used = 0; - while (at < path.used && !path.string[at]) ++at; if (path.string[at] == f_path_separator_s.string[0]) { diff --git a/level_1/fl_path/c/path.h b/level_1/fl_path/c/path.h index 59a507a92..619632e84 100644 --- a/level_1/fl_path/c/path.h +++ b/level_1/fl_path/c/path.h @@ -42,6 +42,7 @@ extern "C" { * This need not be NULL terminated. * @param canonical * The (allocated) canonical file path. + * This parameter is overwritten rather than being appended to. * This will be NULL terminated at canonical->used + 1. * * @return diff --git a/level_1/fl_path/data/documentation/man/man3/fl_path_canonical.3 b/level_1/fl_path/data/documentation/man/man3/fl_path_canonical.3 index 90b08bffc..65cd4f1f8 100644 --- a/level_1/fl_path/data/documentation/man/man3/fl_path_canonical.3 +++ b/level_1/fl_path/data/documentation/man/man3/fl_path_canonical.3 @@ -26,7 +26,7 @@ The source path to determine what the canonical path is. NULLs within the path a .TP .B canonical -The (allocated) canonical file path. This will be NULL terminated at canonical->used + 1. +The (allocated) canonical file path. This parameter is overwritten rather than being appended to. This will be NULL terminated at canonical->used + 1. .SH STRUCTURES .SS "" -- 2.47.3