diff --git a/tools/misc/xenhypfs.c b/tools/misc/xenhypfs.c index 158b901f42..5145b8969f 100644 --- a/tools/misc/xenhypfs.c +++ b/tools/misc/xenhypfs.c @@ -148,9 +148,14 @@ static int xenhypfs_tree_sub(char *path, unsigned int depth) printf("%*s%s%s\n", depth * 2, "", ent[i].name, ent[i].type == xenhypfs_type_dir ? "/" : ""); if (ent[i].type == xenhypfs_type_dir) { - asprintf(&p, "%s%s%s", path, (depth == 1) ? "" : "/", ent[i].name); + if (asprintf(&p, "%s%s%s", path, (depth == 1) ? "" : "/", + ent[i].name) < 0) { + ret = 2; + break; + } if (xenhypfs_tree_sub(p, depth + 1)) ret = 2; + free(p); } }