shithub: unionfs

Download patch

ref: db287775ae9de502690e87ffaab5baeed76ecf46
parent: acdb94c0914d1090468768500f8eb843f05a0128
author: kvik <kvik@a-b.xyz>
date: Wed May 15 10:19:18 EDT 2019

fix double-free when filewalk returns the same file

this would happen when filewalk returned the same file that it
was passed, which was the case on backwards walks at root.  in
this case we freed the  old  file in walk1, and another free
would happen upon clunking the Fid state.

--- a/unionfs.c
+++ b/unionfs.c
@@ -337,6 +337,7 @@
 			free(d);
 			f->fspath = mkpath(p->fspath, name, nil);
 			f->path = path;
+			filefree(p);
 			return f;
 		}
 		free(path);
@@ -359,7 +360,6 @@
 	if((f = filewalk(p, name)) == nil)
 		return "no file";
 	st->file = f;
-	filefree(p);
 
 	fid->qid = f->qid;
 	return nil;