fixed empty diretory bug

This commit is contained in:
overflowerror 2019-03-08 14:37:38 +01:00
parent fe3d0871ec
commit 9d9aa7fd10

View file

@ -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, " </body>\n");
fprintf(stream, "</html>\n");
free(list);
fclose(stream);
freeDirent(list, number);