Commit 821e2b3a authored by Sergey Lyubka's avatar Sergey Lyubka

Merge pull request #501 from xant/upstream

safety belt : scan_directory() can return without setting arr to a valid value
parents 773efb07 ed1904a7
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment