If the test case changes desc, it *must* point to an allocated buffer

which the driver will free after printing the result.
This commit is contained in:
Dag-Erling Smørgrav 2014-12-29 12:56:35 +00:00 committed by des
parent 79967f2844
commit eb10ce6d05
2 changed files with 12 additions and 12 deletions

View file

@ -146,18 +146,18 @@ t_run_test(struct t_test *t, int n)
char *desc;
int ret;
desc = t->desc ? t->desc : "no description";
desc = t->desc;
ret = (*t->func)(&desc, t->arg);
if (ret > 0) {
printf("ok %d - %s\n", n + 1, desc);
return (1);
} else if (ret < 0) {
printf("ok %d - # skip %s\n", n + 1, desc);
return (1);
} else {
printf("not ok %d - %s\n", n + 1, desc);
return (0);
}
if (ret > 0)
printf("ok %d - ", n + 1);
else if (ret < 0)
printf("ok %d - # skip ", n + 1);
else
printf("not ok %d - ", n + 1);
printf("%s\n", desc ? desc : "no description");
if (desc != t->desc)
free(desc);
return (ret);
}
/*

View file

@ -491,7 +491,7 @@ t_malloc_leaked(char **desc, void *arg CRYB_UNUSED)
asprintf(desc, "%lu allocation(s) leaked", nleaked);
return (0);
} else {
*desc = "no memory leaked";
asprintf(desc, "%s", "no memory leaked");
return (1);
}
#else