On Thu, Jul 04, 2024 at 02:00:30PM +0800, runxiyu-ld/isync--- via isync-devel 
wrote:
Note that I only experience this error when ~/.local/share/mail/runxiyu
is empty. If I have a successful previous run, subsequent syncs work.

Running it causes a segfault.

[...]

thanks for the thorough report!

you could make it even better by using -g3 instead of -g (that should
get rid of the "<optimized out>" gunk) and isync's --debug instead of
--verbose. but never mind, it's good enough this time.

does the attached patch help?

From 14e432d890896d996b4c68576303329d66eb6b28 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <o...@users.sf.net>
Date: Thu, 4 Jul 2024 09:09:17 +0200
Subject: [PATCH] don't try to qsort() NULL array

while this actually works due to the array size being zero, it's
undefined behavior which makes gcc eliminate a subsequent null check in
the calling function.
---
 src/main_sync.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main_sync.c b/src/main_sync.c
index 226e3249..fff944c3 100644
--- a/src/main_sync.c
+++ b/src/main_sync.c
@@ -186,7 +186,8 @@ filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns
 			boxarr[num] = NULL;
 		}
 	}
-	qsort( boxarr, num, sizeof(*boxarr), cmp_box_names );
+	if (boxarr)
+		qsort( boxarr, num, sizeof(*boxarr), cmp_box_names );
 	return boxarr;
 }

--
2.44.0.701.g2cf7baacf3.dirty

_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to