Skip to content

Commit c06e9c4

Browse files
committed
Fix a possible leak of a file descriptor
When mmap fails for any reason, the fd must be closed. Coverity Scan found this issue.
1 parent 93c0474 commit c06e9c4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/util/pm_string.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
189189

190190
source = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
191191
if (source == MAP_FAILED) {
192+
close(fd);
192193
return PM_STRING_INIT_ERROR_GENERIC;
193194
}
194195

0 commit comments

Comments
 (0)