Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Segmentation fault at exit with set -u and pipe



On Fri, Feb 3, 2023 at 4:32 PM Cebtenzzre <cebtenzzre@xxxxxxxxx> wrote:
>
> It appears that cleanfilelists frees memory that is
> sometimes referenced later in the exit process.

Try this.
diff --git a/Src/jobs.c b/Src/jobs.c
index 4863962b9..59ddd952e 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1372,8 +1372,10 @@ cleanfilelists(void)
 
     DPUTS(shell_exiting >= 0, "BUG: cleanfilelists() before exit");
  
-    for (i = 1; i <= maxjob; i++)
+    for (i = 1; i <= maxjob; i++) {
 	deletefilelist(jobtab[i].filelist, 0);
+	jobtab[i].filelist = 0;
+    }
 }
 
 /**/
@@ -1531,8 +1533,10 @@ havefiles(void)
     int i;
 
     for (i = 1; i <= maxjob; i++)
-	if (jobtab[i].stat && jobtab[i].filelist)
+	if (jobtab[i].stat && jobtab[i].filelist &&
+	    peekfirst(jobtab[i].filelist)) {
 	    return 1;
+	}
     return 0;
 
 }


Messages sorted by: Reverse Date, Date, Thread, Author