Fix a possible leak of a file descriptor

The same issue as https://github.com/ruby/prism/pull/3246

Coverity Scan found this issue.
This commit is contained in:
Yusuke Endoh 2024-11-28 12:57:28 +09:00
parent d94ae8b8f9
commit c0e607cef1
Notes: git 2024-11-28 04:26:48 +00:00

View File

@ -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;
}