From c0e607cef1fb6e1795b0969c1533b63dc349d484 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Thu, 28 Nov 2024 12:57:28 +0900 Subject: [PATCH] Fix a possible leak of a file descriptor The same issue as https://github.com/ruby/prism/pull/3246 Coverity Scan found this issue. --- prism_compile.c | 1 + 1 file changed, 1 insertion(+) 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; }