Skip to content

Commit

Permalink
Fix crash in getFilePathMaxTailNumPlus1
Browse files Browse the repository at this point in the history
Check that result of `opendir()` is not `NULL`, before calling `readdir()` as later might crash if called with NULL argument, as one can see in https://godbolt.org/z/f3daEbPTx

This was the underlying source of crash in pytorch-2.1 on aarch64 platform when run inside the docker container, see pytorch/pytorch#111695 (comment)
  • Loading branch information
malfet authored and kawakami-k committed Oct 24, 2023
1 parent 7d436da commit 6023a94
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/util_impl_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class CpuInfoLinux : public CpuInfo {
strncat(file_pattern, "[0-9]+", 16);

DIR *dir = opendir(dir_path);
if (dir == NULL)
return retVal;
struct dirent *dp;

dp = readdir(dir);
Expand Down

0 comments on commit 6023a94

Please sign in to comment.