LibC: Fix scandir not checking for allocation failure

This commit is contained in:
Michel Hermier 2022-01-12 02:55:09 +01:00 committed by Andreas Kling
parent 1af072e0f3
commit adfdb63e02
Notes: sideshowbarker 2024-07-17 20:45:29 +09:00

View File

@ -278,6 +278,9 @@ int scandir(const char* dir_name,
const int size = tmp_names.size();
auto** names = static_cast<struct dirent**>(kmalloc_array(size, sizeof(struct dirent*)));
if (names == nullptr) {
return -1;
}
for (auto i = 0; i < size; i++) {
names[i] = tmp_names[i];
}