ruby-changes:59751
From: Nobuyoshi <ko1@a...>
Date: Mon, 20 Jan 2020 09:50:02 +0900 (JST)
Subject: [ruby-changes:59751] bdef392ec6 (master): Fixed double closedir
https://git.ruby-lang.org/ruby.git/commit/?id=bdef392ec6 From bdef392ec66168578053fabf8a81de48fd9e980c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 20 Jan 2020 09:30:17 +0900 Subject: 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. diff --git a/dir.c b/dir.c index d54ba64..0957800 100644 --- a/dir.c +++ b/dir.c @@ -2252,8 +2252,10 @@ glob_opendir(ruby_glob_entries_t *ent, DIR *dirp, int flags, rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/dir.c#L2252 } 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]), -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/