mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
884897dbe2
commit
bdef392ec6
1 changed files with 4 additions and 2 deletions
6
dir.c
6
dir.c
|
@ -2252,8 +2252,10 @@ glob_opendir(ruby_glob_entries_t *ent, DIR *dirp, int flags, rb_encoding *enc)
|
||||||
}
|
}
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
if (count < capacity) {
|
if (count < capacity) {
|
||||||
if (!(newp = GLOB_REALLOC_N(ent->sort.entries, count)))
|
if (!(newp = GLOB_REALLOC_N(ent->sort.entries, count))) {
|
||||||
goto nomem;
|
glob_dir_finish(ent, 0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
ent->sort.entries = newp;
|
ent->sort.entries = newp;
|
||||||
}
|
}
|
||||||
ruby_qsort(ent->sort.entries, ent->sort.count, sizeof(ent->sort.entries[0]),
|
ruby_qsort(ent->sort.entries, ent->sort.count, sizeof(ent->sort.entries[0]),
|
||||||
|
|
Loading…
Add table
Reference in a new issue