Fix SVACE defect in IoT.js (fs.scandir)
@@ -407,6 +407,12 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) {
cnt++;
}
+ if (cnt > 0 && dents == NULL) {
+ closedir(dir);
+ cnt = -1;
+ goto error;
+ }
+
/* Allcoate memory for the directory entries. */
dents = (uv__dirent_t**) malloc(sizeof (uv__dirent_t*) * cnt);
