--- cvs_ltp.orig/testcases/kernel/ipc/pipeio/pipeio.c	2006-12-14 06:55:22.000000000 +0800
+++ cvs_ltp/testcases/kernel/ipc/pipeio/pipeio.c	2008-09-16 20:52:26.000000000 +0800
@@ -56,6 +56,7 @@ char *TCID="pipeio"; 		/* Test program i
 int TST_TOTAL=1;    		/* Total number of test cases. */
 extern int Tst_count;		/* Test Case counter for tst_* routines */
 
+#define SAFE_FREE(p) { if(p) { free(p); (p)=NULL; } }
 
 /* To avoid extensive modifications to the code, use this bodge */
 #define exit(x) myexit(x)
@@ -126,8 +127,8 @@ char *av[];
 	int parent_wait = 0;	/* max time to wait between reads, 1 == no wait*/
 	int ndelay = O_NDELAY;	/* additional flag to open */
 	long clock;
-	char *writebuf;
-	char *readbuf;
+	char *writebuf = NULL;
+	char *readbuf = NULL;
 	double d;
 	char   *cp;
         extern char *optarg;
@@ -425,7 +426,8 @@ char *av[];
 	if ((writebuf = (char *) malloc(size)) == NULL ||
 	    (readbuf = (char *) malloc(size)) == NULL) {
 		tst_resm (TFAIL, "malloc() failed: %s", strerror(errno));
-		
+  		SAFE_FREE(writebuf);
+		SAFE_FREE(readbuf);	
 		exit(1);
 	}
 
@@ -657,6 +659,8 @@ output:
 			unlink(pname);
 	}
 
+ 	SAFE_FREE(writebuf);
+	SAFE_FREE(readbuf);	
 	return (error);
 }
 
