diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-01-20 09:30:17 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-01-20 09:49:27 +0900 |
commit | bdef392ec66168578053fabf8a81de48fd9e980c (patch) | |
tree | eee2f6c4046ab6c497fcb2f7234f3e7dea387a44 /dir.c | |
parent | 884897dbe20674d3a741cbfacac8cbca862675d0 (diff) |
Fixed double closedir
In the case that shinking the entries buffer to the exact size
failed, `dirp` is already closed. Found by mame with Coverity
Scan.
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -2252,8 +2252,10 @@ glob_opendir(ruby_glob_entries_t *ent, DIR *dirp, int flags, rb_encoding *enc) } closedir(dirp); if (count < capacity) { - if (!(newp = GLOB_REALLOC_N(ent->sort.entries, count))) - goto nomem; + if (!(newp = GLOB_REALLOC_N(ent->sort.entries, count))) { + glob_dir_finish(ent, 0); + return NULL; + } ent->sort.entries = newp; } ruby_qsort(ent->sort.entries, ent->sort.count, sizeof(ent->sort.entries[0]), |