diff --git a/path.c b/path.c index cc9e007f38b3fad7233b8b72836aeea8a0aece5a..0d2bf149e4eb12f052c67ae38d2a8c264913a909 100644 --- a/path.c +++ b/path.c @@ -46,7 +46,10 @@ static struct pathelem *new_entry(const char *root, { struct pathelem *new = malloc(sizeof(*new)); new->name = strdup(name); - asprintf(&new->pathname, "%s/%s", root, name); + if (asprintf(&new->pathname, "%s/%s", root, name) == -1) { + printf("Cannot allocate memory\n"); + exit(1); + } new->num_entries = 0; return new; }