aboutsummaryrefslogtreecommitdiff
path: root/coreutils/test.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-27 03:39:50 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-27 03:39:50 +0000
commitfe3e1776ada6bf8cf39e08f4974bd6cc6d29175d (patch)
tree0e7446276dcdff5e0d783911b72a8e03e9b07014 /coreutils/test.c
parent1c9ad62d26e65c7159a2a1752456da34def17632 (diff)
downloadbusybox-w32-fe3e1776ada6bf8cf39e08f4974bd6cc6d29175d.tar.gz
busybox-w32-fe3e1776ada6bf8cf39e08f4974bd6cc6d29175d.tar.bz2
busybox-w32-fe3e1776ada6bf8cf39e08f4974bd6cc6d29175d.zip
test: close bug 1371
test: plug a memory leak
Diffstat (limited to 'coreutils/test.c')
-rw-r--r--coreutils/test.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index df8387b14..fd10e6845 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -246,7 +246,7 @@ static void syntax(const char *op, const char *msg)
246 if (op && *op) { 246 if (op && *op) {
247 bb_error_msg("%s: %s", op, msg); 247 bb_error_msg("%s: %s", op, msg);
248 } else { 248 } else {
249 bb_error_msg("%s", msg); 249 bb_error_msg("%s: %s"+4, msg);
250 } 250 }
251 longjmp(leaving, 2); 251 longjmp(leaving, 2);
252} 252}
@@ -319,7 +319,7 @@ static int binop(void)
319{ 319{
320 const char *opnd1, *opnd2; 320 const char *opnd1, *opnd2;
321 struct t_op const *op; 321 struct t_op const *op;
322 smallint val1, val2; 322 arith_t val1, val2;
323 323
324 opnd1 = *t_wp; 324 opnd1 = *t_wp;
325 (void) t_lex(*++t_wp); 325 (void) t_lex(*++t_wp);
@@ -363,8 +363,8 @@ static int binop(void)
363 { 363 {
364 struct stat b1, b2; 364 struct stat b1, b2;
365 365
366 if (!(!stat(opnd1, &b1) && !stat(opnd2, &b2))) 366 if (stat(opnd1, &b1) || stat(opnd2, &b2))
367 return 0; /* false, since stat failed */ 367 return 0; /* false, since at least one stat failed */
368 if (op->op_num == FILNT) 368 if (op->op_num == FILNT)
369 return b1.st_mtime > b2.st_mtime; 369 return b1.st_mtime > b2.st_mtime;
370 if (op->op_num == FILOT) 370 if (op->op_num == FILOT)
@@ -559,7 +559,12 @@ static void initialize_group_array(void)
559{ 559{
560 ngroups = getgroups(0, NULL); 560 ngroups = getgroups(0, NULL);
561 if (ngroups > 0) { 561 if (ngroups > 0) {
562 group_array = xmalloc(ngroups * sizeof(gid_t)); 562 /* FIXME: ash tries so hard to not die on OOM,
563 * and we spoil it with just one xrealloc here */
564 /* We realloc, because bb_test can be entered repeatedly by shell.
565 * Testcase (ash): 'while true; do test -x some_file; done'
566 * and watch top. (some_file must have owner != you) */
567 group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
563 getgroups(ngroups, group_array); 568 getgroups(ngroups, group_array);
564 } 569 }
565} 570}