This caused coreutils tests/readlink/can-e.sh to fail
as that tests reading the current dir after it's removed.

* lib/canonicalize.c (canonicalize_filename_mode_stk): Move variable
initialization before goto which may skip them.
---
 ChangeLog          |  6 ++++++
 lib/canonicalize.c | 14 +++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 98a9146cb9..a813d38413 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-12-10  Pádraig Brady  <[email protected]>
+
+       canonicalize: fix UMR introduced in recent change
+       * lib/canonicalize.c (canonicalize_filename_mode_stk): Move variable
+       initialization before goto which may skip them.
+
 2025-12-10  Pádraig Brady  <[email protected]>
 
        human: fix UMR introduced in recent change
diff --git a/lib/canonicalize.c b/lib/canonicalize.c
index 49eaffd4f1..adbccaac87 100644
--- a/lib/canonicalize.c
+++ b/lib/canonicalize.c
@@ -208,6 +208,13 @@ canonicalize_filename_mode_stk (const char *name, 
canonicalize_mode_t can_mode,
   char *dest;
   char const *start;
 
+  bool logical = (can_mode & CAN_NOLINKS) != 0;
+
+  int num_links = 0;
+  Hash_table *ht = NULL;
+  bool end_in_extra_buffer = false;
+  bool failed = true;
+
   if (!IS_ABSOLUTE_FILE_NAME (name))
     {
       while (!getcwd (bufs->rname.data, bufs->rname.length))
@@ -271,13 +278,6 @@ canonicalize_filename_mode_stk (const char *name, 
canonicalize_mode_t can_mode,
       start = name + prefix_len;
     }
 
-  bool logical = (can_mode & CAN_NOLINKS) != 0;
-
-  int num_links = 0;
-  Hash_table *ht = NULL;
-  bool end_in_extra_buffer = false;
-  bool failed = true;
-
   for (; *start;)
     {
       /* Skip sequence of multiple file name separators.  */
-- 
2.51.1


Reply via email to