

There was a very strange and weird bug inside jfsck() which can lead to
SIGSEGV inside malloc(), for instance. In the end it was just a very weird
corner case of a buffer being misfreed. This patch moves the free() where it
belongs.



---

 cur-root/libjio.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff -puN libjio.c~jfsck_buf_free libjio.c
--- cur/libjio.c~jfsck_buf_free	2004-04-05 12:32:09.000000000 -0300
+++ cur-root/libjio.c	2004-04-05 12:32:09.000000000 -0300
@@ -777,6 +777,7 @@ int jfsck(char *name, struct jfsck_resul
 		rv = read(tfd, buf, J_DISKTFIXSIZE);
 		if (rv != J_DISKTFIXSIZE) {
 			res->broken_head++;
+			free(buf);
 			goto loop;
 		}
 		
@@ -785,6 +786,8 @@ int jfsck(char *name, struct jfsck_resul
 		curts->ulen = (size_t) *(buf + 16);
 		curts->offset = (off_t) *(buf + 20);
 
+		free(buf);
+
 		/* if we got here, the transaction was not applied, so we
 		 * check if the transaction file is complete (we only need to
 		 * apply it) or not (so we can't do anything but ignore it) */
@@ -872,8 +875,7 @@ int jfsck(char *name, struct jfsck_resul
 loop:
 		if (tfd > 0)
 			close(tfd);
-		if (buf)
-			free(buf);
+
 		free(curts);
 
 		res->total++;

_
