Merge pull request #501 from xant/upstream

safety belt : scan_directory() can return without setting arr to a valid value
This commit is contained in:
Sergey Lyubka 2015-04-01 20:22:20 +01:00
commit 821e2b3a75

View File

@ -3640,12 +3640,14 @@ static void send_directory_listing(struct connection *conn, const char *dir) {
sort_direction, sort_direction, sort_direction);
num_entries = scan_directory(conn, dir, &arr);
qsort(arr, num_entries, sizeof(arr[0]), compare_dir_entries);
for (i = 0; i < num_entries; i++) {
print_dir_entry(&arr[i]);
NS_FREE(arr[i].file_name);
if (arr) {
qsort(arr, num_entries, sizeof(arr[0]), compare_dir_entries);
for (i = 0; i < num_entries; i++) {
print_dir_entry(&arr[i]);
NS_FREE(arr[i].file_name);
}
NS_FREE(arr);
}
NS_FREE(arr);
write_terminating_chunk(conn);
close_local_endpoint(conn);