summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2024-11-28 12:57:28 +0900
committerYusuke Endoh <mame@ruby-lang.org>2024-11-28 13:26:26 +0900
commitc0e607cef1fb6e1795b0969c1533b63dc349d484 (patch)
tree76199ae76a4e92fde8682f33ec9452d3f66fb7c0
parentd94ae8b8f980ae838f5d641584fe99a269f68857 (diff)
Fix a possible leak of a file descriptor
The same issue as https://github.com/ruby/prism/pull/3246 Coverity Scan found this issue.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12192
-rw-r--r--prism_compile.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/prism_compile.c b/prism_compile.c
index 84f206ab8f..32d0c13223 100644
--- a/prism_compile.c
+++ b/prism_compile.c
@@ -10900,6 +10900,7 @@ pm_read_file(pm_string_t *string, const char *filepath)
source = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
if (source == MAP_FAILED) {
+ close(fd);
return PM_STRING_INIT_ERROR_GENERIC;
}