Subject: Re: [bug-diffutils] bug#64316: ASAN failures in dir.c
From: Paul Eggert <[email-masked]>
To: Gisle Vanem <[email-masked]>
Cc: [email-masked]
Date: Tue, 27 Jun 2023 09:40:06 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks for reporting that bug, which I recently introduced. I installed 
the attached to fix it.

From d4a63b11fc6b62f538dacfd7db47270dc577ac81 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Tue, 27 Jun 2023 09:36:27 -0700
Subject: [PATCH] diff: fix xpalloc typo

Problem reported by Gisle Vanem (Bug#64316).
* src/dir.c (dir_read): Also set local var cache.
---
 src/dir.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/dir.c b/src/dir.c
index 6930626..4bcfceb 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -96,8 +96,9 @@ dir_read (struct file_data const *dir, struct dirdata *dirdata)
             continue;
 
           if (data_alloc - data_used < d_size)
-	    dirdata->data = xpalloc (dirdata->data, &data_alloc,
-				     d_size - (data_alloc - data_used), -1, 1);
+	    dirdata->data = data
+	      = xpalloc (data, &data_alloc,
+			 d_size - (data_alloc - data_used), -1, 1);
           memcpy (data + data_used, d_name, d_size);
           data_used += d_size;
           nnames++;
-- 
2.39.2