svn commit: trunk/busybox/coreutils

vda at busybox.net vda at busybox.net
Sat May 26 20:39:52 PDT 2007


Author: vda
Date: 2007-05-26 20:39:50 -0700 (Sat, 26 May 2007)
New Revision: 18698

Log:
test: close bug 1371
test: plug a memory leak



Modified:
   trunk/busybox/coreutils/test.c


Changeset:
Modified: trunk/busybox/coreutils/test.c
===================================================================
--- trunk/busybox/coreutils/test.c	2007-05-27 00:53:41 UTC (rev 18697)
+++ trunk/busybox/coreutils/test.c	2007-05-27 03:39:50 UTC (rev 18698)
@@ -246,7 +246,7 @@
 	if (op && *op) {
 		bb_error_msg("%s: %s", op, msg);
 	} else {
-		bb_error_msg("%s", msg);
+		bb_error_msg("%s: %s"+4, msg);
 	}
 	longjmp(leaving, 2);
 }
@@ -319,7 +319,7 @@
 {
 	const char *opnd1, *opnd2;
 	struct t_op const *op;
-	smallint val1, val2;
+	arith_t val1, val2;
 
 	opnd1 = *t_wp;
 	(void) t_lex(*++t_wp);
@@ -363,8 +363,8 @@
 	{
 		struct stat b1, b2;
 
-		if (!(!stat(opnd1, &b1) && !stat(opnd2, &b2)))
-			return 0; /* false, since stat failed */
+		if (stat(opnd1, &b1) || stat(opnd2, &b2))
+			return 0; /* false, since at least one stat failed */
 		if (op->op_num == FILNT)
 			return b1.st_mtime > b2.st_mtime;
 		if (op->op_num == FILOT)
@@ -559,7 +559,12 @@
 {
 	ngroups = getgroups(0, NULL);
 	if (ngroups > 0) {
-		group_array = xmalloc(ngroups * sizeof(gid_t));
+		/* FIXME: ash tries so hard to not die on OOM,
+		 * and we spoil it with just one xrealloc here */
+		/* We realloc, because bb_test can be entered repeatedly by shell.
+		 * Testcase (ash): 'while true; do test -x some_file; done'
+		 * and watch top. (some_file must have owner != you) */
+		group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
 		getgroups(ngroups, group_array);
 	}
 }



More information about the busybox-cvs mailing list