diff --git a/src/files.c b/src/files.c index d6feff2..1514297 100644 --- a/src/files.c +++ b/src/files.c @@ -35,6 +35,9 @@ int scandirSort(const struct dirent** a, const struct dirent** b) { } void freeDirent(struct dirent** list, int number) { + if (list == NULL || number == 0) + return; + for(int i = 0; i < number; i++) { free(list[i]); } @@ -88,7 +91,6 @@ int showIndex(int fd, const char* path, const char* documentRoot) { fprintf(stream, " \n"); fprintf(stream, "\n"); - free(list); fclose(stream); freeDirent(list, number);