summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test-path-utils.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/test-path-utils.c b/test-path-utils.c
index c3adcd87b8..0c15f1821f 100644
--- a/test-path-utils.c
+++ b/test-path-utils.c
@@ -8,21 +8,14 @@
*/
static int normalize_ceiling_entry(struct string_list_item *item, void *unused)
{
- const char *ceil = item->string;
- int len = strlen(ceil);
- char buf[PATH_MAX+1];
+ char *ceil = item->string;
- if (len == 0)
+ if (!*ceil)
die("Empty path is not supported");
- if (len > PATH_MAX)
- die("Path \"%s\" is too long", ceil);
if (!is_absolute_path(ceil))
die("Path \"%s\" is not absolute", ceil);
- if (normalize_path_copy(buf, ceil) < 0)
+ if (normalize_path_copy(ceil, ceil) < 0)
die("Path \"%s\" could not be normalized", ceil);
- len = strlen(buf);
- free(item->string);
- item->string = xstrdup(buf);
return 1;
}
@@ -166,7 +159,7 @@ static struct test_data dirname_data[] = {
int main(int argc, char **argv)
{
if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
- char *buf = xmalloc(PATH_MAX + 1);
+ char *buf = xmallocz(strlen(argv[2]));
int rv = normalize_path_copy(buf, argv[2]);
if (rv)
buf = "++failed++";