]> Kevux Git Server - fll/commitdiff
Bugfix: The fl_path_canonical() is not consistently resetting canonical.used.
authorKevin Day <Kevin@kevux.org>
Sun, 11 Jan 2026 22:26:48 +0000 (16:26 -0600)
committerKevin Day <Kevin@kevux.org>
Sun, 11 Jan 2026 22:26:48 +0000 (16:26 -0600)
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
level_1/fl_path/c/path.h
level_1/fl_path/data/documentation/man/man3/fl_path_canonical.3

index 84630665e1f1d23d9f2d04e587cd452cd7c5467e..fe5f82ee9be96db56309b4d7858aa19f41c40a59 100644 (file)
@@ -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]) {
index 59a507a920627b42be6ff981e53ec73d3e5aefcf..619632e84e03a26099e219dd898c6883d66ed050 100644 (file)
@@ -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
index 90b08bffcd21100c05f63cdcdac9c537bf25dd31..65cd4f1f8f3da83e4a044abb943c5255ce58cf71 100644 (file)
@@ -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 ""